I am using fetch to make an API call. After successfully making the API call I get a good status code, but when trying to evaluate the status code my "if" statement always goes to "else" even though my status code is "200". Please see the below snippet:
const fetch = require("node-fetch");
var accessToken = "Bearer <ACCESS TOKEN>";
var url = '<URL>';
var headers3 = {
'Authorization': accessToken
};
const delAPI = async url => {
try {
const response = await fetch(url, {method: "DELETE", headers: headers3});
const res = await response.status;
console.log(response.status);
return res.status;
} catch (error) {
console.log(error);
}
};
delAPI(url).then(
status => {
const res = status;
if (res === 200) {
console.log("Integration has been deleted");
} else {
console.log("Integration is either disabled or not installed");
}
});I think the issue is within the condition "(res === 200)" and it may not be evaluating "res" as my actual response.status from the async function delAPI? I have tried numerous iterations to get around this and have had no luck thus far. Any assistance is appreciated to get me going in the correct direction....
Aucun commentaire:
Enregistrer un commentaire