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

323
Views
Axios Post Request equivalente de Python

Tengo el siguiente código de Python:

 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

Quería convertir esto a JavaScript/Axios con ReactNative. Esto es lo que probé hasta ahora:

 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() da una imagen. Sin embargo, es posible que no sea instantáneo, así que hago un await luego then Luego quería publicar eso con Axios. Esto me está dando errores 404. ¿Qué estoy haciendo mal?

También probé:

 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')

Por favor, hágamelo saber cómo solucionarlo! ¡Muchas gracias!

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!