Sign in | Sign up

Correct Syntax for Nutrient Request

Tagged:

Currently contains 1 post

Avatar

August 26, 2019 01:26

domjag

I get bad request I know its the syntax – what is the correct syntax for sending a nutrient POST? The following throws a 404 bad request (I’ve taken out my keys for the example)
I get bad request I know its the syntax – what is the correct syntax for sending a nutrient POST? The following throws a 404 bad request (I’ve taken out my keys for the example)
const url = ‘https://trackapi.nutritionix.com/v2/natural/nutrients’;

let req = new Request(url, { method: ‘POST’, headers: { ‘Content-Type’: ‘application/json’, ‘x-app-id’: ‘bxxxxxx’, ‘x-app-key’: ‘9dxxxxxxxxxxxxxxxxxxxxxxxxx’, ‘x-remote-user-id’: ‘0’, // ‘Content-Type’: ‘application/x-www-form-urlencoded’, }, data: { “query”: “chicken”, “num_servings”: 1, “line_delimited”: false, “use_raw_foods”: false, “include_subrecipe”: false, “use_branded_foods”: false, “locale”: “en_US” } }); fetch(req) .then( …
Reply to thread