Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
Javascript API request with Nutritionix API fails

I am trying to fetch data from Nutritionix API to get the nutrition data by food name. I succesfully fetched foods by search keyword but my second request fails. Here's the test code(xxx is just placeholder):

async function getNutrition() {
    const response = await fetch(`https://trackapi.nutritionix.com/v2/natural/nutrients`, {
        method: 'POST',
        headers: {
            'x-app-id': 'xxx',
            'x-app-key': 'xxx',
            'x-remote-user-id': '0',
        },
        body: {
            'query':'apple'
        }
    })
    const data = await response.json()
    return data
}

I have tried the same with JSON.stringify too but the error message is the same: "child "query" fails because ["query" is required]", id: "7323ff62-a995-4112-8a61-7f7f758d7cd8"

I hope someone can help me with this. I'm at the very beginning of using APIs and it is a little bit confusing for me.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!