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

321
Visualizações
Axios Post Request equivalent from Python

I have the following Python Code:

import requests
img = 'IMG_6747.jpg' //Image File
api_user_token = 'KEY'
headers = {'Authorization': 'Bearer ' + api_user_token}

url = 'https://api.logmeal.es/v2/recognition/complete'
resp = requests.post(url,files={'image': open(img, 'rb')},headers=headers)
print(resp.json()) # display nutritional info

I wanted to convert this to JavaScript/Axios with ReactNative. Here is what I tried so far:

let api_user_token = 'KEY';
let headers = {'Authorization': 'Bearer ' + api_user_token}

let answer = await this.camera.takePictureAsync().then(
        (photo)=> axios.post('https://api.logmeal.es/v2/recognition/complete', 
        { image: photo }, {headers})
      ).catch((e) => {        console.error(e.response.status);
      })

this.camera.takePictureAsync() gives an image. However that may not be instant, so I do an await then a then Then I wanted to post that with Axios. This is giving me 404 errors. What am I doing wrong?

I also tried:

 let photo = await this.camera.takePictureAsync()
      var data = new FormData();
      data.append('image', photo); 
        console.log("hi")   
        console.log(answer)
      this.props.navigation.navigate('Home')

Please let me know how to fix it! Thank you so much!

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