Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

218
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda