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

97
Vistas
Requesting user information from api with axios in react

so I'm doing this assignment and can't seem to understand how to make the request that I'm being asked to do, the information given is the following (going to be editing the names):

api url: https://this.api.com/entity

api apikey: somePa$$word

and 2 endpoints to get information based on an user info:

/category/userID=11111111

/category/userPassport=20111111113

An example of usage was given: screenshot of example

I'm not really clear on how to write this and so far every post I found doesn't work.

What I have so far:

const [apiData, setApiData] = useState(null);
  useEffect(() => {
    axios
      .get(
         //testing attaching the endpoint as the example shows?
        'https://this.api.com/entity/category/userID=11111111', 
        {
          headers: {
            Authorization: `Apikey somePa$$word`,
          },
        }
      )
      .then((res) => {
        setApiData(res.data);
        console.log('axios: ' + res.data);
      });
      .catch((error) => {
        console.log('axios: ' + error);
      });
  }, []);

I get these errors in the console: console errors

First time I ask a question here and I hope the info I provided is enough, if anything else is needed pls let me know.

Thanks you

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

try this

axios
      .get(
         //testing attaching the endpoint as the example shows?
        'https://this.api.com/entity/category/userID=11111111', 
        {
          headers: {
            Authorization: `Apikey somePa$$word`,
            'Access-Control-Allow-Origin': '*',
          },
        }
      )
about 4 years ago · Santiago Trujillo Denunciar
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