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

112
Vistas
Can't use an API due to CORS in Reacr fetch

I'm trying to make a get request in React using javascript fetch, but i can't solve the problem of cors.

The doc of the Api that i'm trying to use is here: "https://docs.abuseipdb.com/#check-endpoint".

Below the code:

export async function getAbuseipInfo(ip, apiKey) {

    const baseUrl = "https://api.abuseipdb.com/api/v2/check?ipAddress=";

        console.log(baseUrl + ip);
        console.log(apiKey);

        await fetch(baseUrl + ip, {
            method: 'GET',
            mode: 'no-cors', //with this in no-cors mode the value Key is not sended and return 401.
            headers: {
                'Key': apiKey,
                'Accept': 'application/json',
                'Access-Control-Allow-Methods': '*', //test to allow all but not working.
                'Access-Control-Allow-Headers': '*',
                'Access-Control-Allow-Origin': '*'
            },
        })
            .then(response => response.json())
            .then(data => {
                console.log('Success:', data);
            })
            .catch((error) => {
                console.error('Error:', error);
            });
}

I tried without mode: 'no-corse' but i get the cors block.

Thanks in advance.

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