Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda