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

125
Views
La búsqueda de API no responde

Estaba trabajando en una aplicación React que obtiene datos de https://restcountries.com/v2/all y ahora tengo un error.

 useEffect(() => { fetch(`https://restcountries.com/v2/all`) .then((r) => r.json()) .then((data) => { if (data !== undefined) { setCountries(data); } else { alert('Can´t Load Data'); } }); }, []);

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

**

use este formato con encabezado

** ##

 // Example POST method implementation: async function postData(url = '', data = {}) { // Default options are marked with * const response = await fetch(url, {`enter code here` method: 'POST', // *GET, POST, PUT, DELETE, etc. mode: 'cors', // no-cors, *cors, same-origin cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached credentials: 'same-origin', // include, *same-origin, omit headers: { 'Content-Type': 'application/json' // 'Content-Type': 'application/x-www-form-urlencoded', }, redirect: 'follow', // manual, *follow, error referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url body: JSON.stringify(data) // body data type must match "Content-Type" header }); return response.json(); // parses JSON response into native JavaScript objects } }, []);
about 4 years ago · Juan Pablo Isaza Report

0

Está recibiendo un error de CORS, lo que significa que el dominio de destino de api (restcountries) no permite que otros dominios obtengan datos. La solución a este problema es un navegador del lado del servidor o un navegador sin cabeza. Como selenio y titiritero

https://www.selenium.dev/

https://github.com/puppeteer

Pero lo he probado y la API me está dando datos en el navegador con el mismo código de búsqueda. No puedo reproducir el problema. Es un problema con otra cosa

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!