@passioncloud/navclient
Advanced tools
Comparing version 1.0.6 to 1.0.7
{ | ||
"name": "@passioncloud/navclient", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"main": "src/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -35,6 +35,33 @@ const NavClient = require('./nav-client.js'); | ||
const result = await this.axios(config); | ||
// const result = await this.axios.post('http://www.google.com'); //(config); | ||
return result.data; | ||
let { data } = result; | ||
// handle paged data | ||
let odataNextLink = data['odata.nextLink'] | ||
while(odataNextLink && data.value?.length) { | ||
odataNextLink += '&$format=json' | ||
const nextConfig = { ...config, url: odataNextLink } | ||
const nextResult = await this.axios(nextConfig) | ||
const nextData = nextResult.data | ||
const newOdataNextLink = nextData['odata.nextLink'] + '&$format=json' | ||
console.log({ | ||
odataNextLink, newOdataNextLink, same: odataNextLink === newOdataNextLink | ||
}) | ||
const odataNextLinkSearchParams = new URLSearchParams(odataNextLink) | ||
const newOdataNextLinkSearchParams = new URLSearchParams(newOdataNextLink) | ||
const currentSkipToken = odataNextLinkSearchParams.get('$skiptoken') | ||
const newSkipToken = newOdataNextLinkSearchParams.get('$skiptoken') | ||
// console.log({ odataNextLinkSearchParams, newOdataNextLinkSearchParams, currentSkipToken, newSkipToken }) | ||
if(currentSkipToken === newSkipToken) { | ||
// if its the same link as the old one, break, do not go repeat the loop | ||
// console.log('same') | ||
break; | ||
} | ||
odataNextLink = nextData['odata.nextLink'] | ||
data["odata.nextLink"] = odataNextLink | ||
data.value.push(...nextData.value) | ||
// console.log({ data }) | ||
} | ||
return data; | ||
} | ||
catch (error) { | ||
console.log({ e: error }) | ||
const odataError = error.response?.data && JSON.stringify(error.response.data) | ||
@@ -49,2 +76,3 @@ let specificOdataError = error.response?.data; | ||
} | ||
console.log({ msg }) | ||
throw new Error(msg); | ||
@@ -51,0 +79,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20229
537