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

288
Visualizações
How to handle API request that does not throw catch? (403 error)

Tried to access blob storage API with the following method but getting 403 return without error throw(this happen because I'm trying to access file that does not exist/no permission). How should such error be handled? .catch is already applied while calling the API.

Background.. I'm trying to make mistake by purpose to get a file inside Azure blob storage. I do expect 403 and I wish to handle this properly.

Get method

 getReq = async url => {
    return new Promise((resolve, reject) => {
      axios
        .get(url)
        .then(function (response) {
          resolve(response.data);
        })
        .catch(function (error) {
          reject(error);
        })
    });
  };

Response received from postman

<?xml version="1.0" encoding="utf-8"?>
<Error>
    <Code>AuthenticationFailed</Code>
    <Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:maskedInfo
Time:maskedInfo</Message>
    <AuthenticationErrorDetail>Signature did not match. String to sign used was 


/blob/maskedInfo/maskedInfo/maskedInfo.json
ReadOnly


2020-08-04
b





</AuthenticationErrorDetail>
</Error>

Tried:

  1. TryCatch does not catch the issue either

Error show from React Native: enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

When you call getReq() method, It will return a Promise. So, You should handle the rejection.

getReq("https://somerandomurl.com")
  .then(res => {
    console.log(res);
  })
  .catch(err => {
    console.error(err);
  })

In await style,

try {
  const res = await getReq("https://somerandomurl.com");
} catch (err) {
  console.error(err);
}
about 4 years ago · Juan Pablo Isaza 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