@plattar/plattar-api
Advanced tools
Comparing version 1.90.11 to 1.90.12-dev
{ | ||
"name": "@plattar/plattar-api", | ||
"version": "1.90.11", | ||
"version": "1.90.12-dev", | ||
"description": "Module for interfacing with the Plattar API (https://www.plattar.com)", | ||
@@ -32,4 +32,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"got": "^11.5.2" | ||
"node-fetch": "^2.6.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
const got = require('got'); | ||
const fetch = require('node-fetch'); | ||
@@ -90,2 +90,3 @@ 'use strict'; | ||
const reqopts = { | ||
method: 'GET', | ||
headers: auth | ||
@@ -102,22 +103,27 @@ }; | ||
got.get(endpoint, reqopts).then((response) => { | ||
const body = response.body; | ||
const json = JSON.parse(body); | ||
fetch(endpoint, reqopts) | ||
.then((res) => { | ||
if (res.ok) { | ||
try { | ||
return res.json(); | ||
} | ||
catch (err) { | ||
return new Error('PlattarQuery.' + target.type() + '.get(' + target.id + ') - critical error occured, cannot proceed'); | ||
} | ||
} | ||
const PlattarUtil = require('../util/plattar-util.js'); | ||
return new Error('PlattarQuery.' + target.type() + '.get(' + target.id + ') - unexpected error occured, cannot proceed. error message is ' + res.statusText); | ||
}) | ||
.then((json) => { | ||
if (json instanceof Error) { | ||
reject(json); | ||
} | ||
else { | ||
const PlattarUtil = require('../util/plattar-util.js'); | ||
PlattarUtil.reconstruct(target, json, options); | ||
PlattarUtil.reconstruct(target, json, options); | ||
resolve(target); | ||
}).catch((error) => { | ||
if (!error || !error.response || !error.response.body) { | ||
reject(new Error('PlattarQuery.' + target.type() + '.get(' + target.id + ') - critical error occured, cannot proceed. error was ' + error)); | ||
return; | ||
} | ||
const body = error.response.body; | ||
const json = JSON.parse(body); | ||
reject(new Error('PlattarQuery.' + target.type() + '.get(' + target.id + ') - ' + json.errors[0].detail)); | ||
}); | ||
resolve(target); | ||
} | ||
}); | ||
}); | ||
@@ -124,0 +130,0 @@ } |
@@ -1,2 +0,2 @@ | ||
const got = require('got'); | ||
const fetch = require('node-fetch'); | ||
@@ -85,2 +85,3 @@ 'use strict'; | ||
const options = { | ||
methid: 'GET', | ||
headers: { | ||
@@ -91,10 +92,13 @@ 'plattar-auth-token': token | ||
got.get(endpoint, options).then((response) => { | ||
this._authToken = { | ||
'plattar-auth-token': token | ||
}; | ||
fetch(endpoint, options).then((res) => { | ||
if (res.ok) { | ||
this._authToken = { | ||
'plattar-auth-token': token | ||
}; | ||
resolve(this); | ||
}).catch((error) => { | ||
reject(new Error('Plattar.auth(token) - failed to validate authentication token at ' + endpoint)); | ||
resolve(this); | ||
} | ||
else { | ||
reject(new Error('Plattar.auth(token) - failed to validate authentication token at ' + endpoint)); | ||
} | ||
}); | ||
@@ -122,8 +126,15 @@ }); | ||
got.get(endpoint).then((response) => { | ||
this._serverLocation = server; | ||
const options = { | ||
methid: 'GET' | ||
}; | ||
resolve(this); | ||
}).catch((error) => { | ||
reject(new Error('Plattar.origin(server) - failed to ping server at ' + endpoint)); | ||
fetch(endpoint, options).then((res) => { | ||
if (res.ok) { | ||
this._serverLocation = server; | ||
resolve(this); | ||
} | ||
else { | ||
reject(new Error('Plattar.origin(server) - failed to ping server at ' + endpoint)); | ||
} | ||
}); | ||
@@ -130,0 +141,0 @@ }); |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
40832
1027
2
3
+ Addednode-fetch@^2.6.0
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedgot@^11.5.2
- Removed@sindresorhus/is@4.6.0(transitive)
- Removed@szmarczak/http-timer@4.0.6(transitive)
- Removed@types/cacheable-request@6.0.3(transitive)
- Removed@types/http-cache-semantics@4.0.4(transitive)
- Removed@types/keyv@3.1.4(transitive)
- Removed@types/node@22.10.7(transitive)
- Removed@types/responselike@1.0.3(transitive)
- Removedcacheable-lookup@5.0.4(transitive)
- Removedcacheable-request@7.0.4(transitive)
- Removedclone-response@1.0.3(transitive)
- Removeddecompress-response@6.0.0(transitive)
- Removeddefer-to-connect@2.0.1(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedget-stream@5.2.0(transitive)
- Removedgot@11.8.6(transitive)
- Removedhttp-cache-semantics@4.1.1(transitive)
- Removedhttp2-wrapper@1.0.3(transitive)
- Removedjson-buffer@3.0.1(transitive)
- Removedkeyv@4.5.4(transitive)
- Removedlowercase-keys@2.0.0(transitive)
- Removedmimic-response@1.0.13.1.0(transitive)
- Removednormalize-url@6.1.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedp-cancelable@2.1.1(transitive)
- Removedpump@3.0.2(transitive)
- Removedquick-lru@5.1.1(transitive)
- Removedresolve-alpn@1.2.1(transitive)
- Removedresponselike@2.0.1(transitive)
- Removedundici-types@6.20.0(transitive)
- Removedwrappy@1.0.2(transitive)