Switching from axios to node-fetch as per review.
This commit is contained in:
parent
5b01320809
commit
306c36c384
|
@ -47,7 +47,6 @@
|
||||||
"@sendgrid/mail": "^7.1.1",
|
"@sendgrid/mail": "^7.1.1",
|
||||||
"@sentry/node": "^5.19.2",
|
"@sentry/node": "^5.19.2",
|
||||||
"aws-sdk": "^2.767.0",
|
"aws-sdk": "^2.767.0",
|
||||||
"axios": "^0.21.0",
|
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"chmodr": "^1.2.0",
|
"chmodr": "^1.2.0",
|
||||||
"csvtojson": "^2.0.10",
|
"csvtojson": "^2.0.10",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const axios = require("axios")
|
const fetch = require("node-fetch")
|
||||||
|
|
||||||
const RequestType = {
|
const RequestType = {
|
||||||
POST: "POST",
|
POST: "POST",
|
||||||
|
@ -71,20 +71,19 @@ module.exports.run = async function({ inputs }) {
|
||||||
}
|
}
|
||||||
const request = {
|
const request = {
|
||||||
method: requestMethod,
|
method: requestMethod,
|
||||||
url,
|
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
requestBody &&
|
requestBody &&
|
||||||
requestBody.length !== 0 &&
|
requestBody.length !== 0 &&
|
||||||
BODY_REQUESTS.indexOf(requestMethod) !== -1
|
BODY_REQUESTS.indexOf(requestMethod) !== -1
|
||||||
) {
|
) {
|
||||||
request.data = JSON.parse(requestBody)
|
request.body = JSON.parse(requestBody)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios(request)
|
const response = await fetch(url, request)
|
||||||
return {
|
return {
|
||||||
response: response.data,
|
response: await response.json(),
|
||||||
success: response.status === 200,
|
success: response.status === 200,
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in New Issue