Sign in | Sign up

Having trouble getting any response for exercise endpoint with fetch api

Tagged:

Currently contains 1 post

Avatar

February 22, 2019 05:16

keurig

let post = {
method: “POST”,
headers: {
“x-app-id”:"",
“x-app-key”:"",
“x-remote-user-id”:“0”,
“Content-Type”:“application/json”
},
body: {
“query”:“ran 4 miles”
}
};

fetch(“https://trackapi.nutritionix.com/v2/natural/exercise”, post)
.then(function(response){
return response.json;
})
.then(function(data) {
console.log(data);
})

I removed the key and id from the code, but this just returns a 400 bad request. I am so confused anyone can help?

Reply to thread