Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

98
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda