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

77
Views
Solicitud a API y esperando respuesta

Necesito enviar la solicitud GET nombre de username=alison&date=2021 al archivo file.php y enviar solicitudes cada 200 ms si no obtengo una de las dos respuestas posibles "sí" o "no", se necesita reenviar la solicitud para obtener la respuesta correcta sin espacios en blanco y no error.

Si obtiene "sí" "no" hacer funciones. al recibir respuestas, realizar diferentes acciones

  1. función después de recibir sí
  2. función después de recibir no
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No estoy 100% seguro de lo que está preguntando aquí, pero este es mi método basado en mi propia interpretación de su pregunta usando una llamada de la API de GitHub. Estamos usando fetch para extraer los datos. Nuestro .entonces es nuestra resolución, y nuestra .captura es nuestro rechazo.

 const url = 'https://api.github.com/users' const callApi = function(fetchUrl){ fetchUrl = url fetch(fetchUrl) .then(response=>{ return response.json(); // Turn data to JSON }) .then(data=>{ // If it was successful, this below will run console.log(data) // Do whatever you want with the data from the API here }) .catch(err=>{ // If it was unsuccessful, this below will run console.log(err); // Console log the error setTimeout(callApi(url), 200); //If it failed, try again in 200ms }) } callApi(url) // Initial function call

Algunas cosas a tener en cuenta: si está utilizando una API que limita la cantidad de llamadas que puede realizar en un día/mes, esto consumirá esas solicitudes asignadas muy rápidamente.

about 4 years ago · Juan Pablo Isaza Report
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!