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

281
Views
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 answers
Answer question

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 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!