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

198
Views
How I can custom axios in Vue

I wrote a response with an axios interceptors and send the return value of this response to a js file named handleResponse. This js file takes the return value and returns a result to me. If I get an error, I have it drop to reject.

  const instance = axios.create({
        baseURL:
            apiName === ""
                ? process.env.VUE_APP_API_URL
                : process.env.VUE_APP_API_URL + apiName,
        withCredentials: false,
        headers: headers
    });


    instance.interceptors.response.use(
        (response) => handleResponse(response),
        (error) => console.log(error)
    );

My handleResponse js file inside interceptors is as follows

export const handleResponse = (response) => {
    return new Promise((resolve) => {
        if (response.data["Success"]) resolve(response.data["Payload"]);
        else {
            let msg = "";
            if (response.data["Information"]) msg = response.data["Information"];

            showError(msg);
             reject(response);
        }
    });
};

Here I make it fall into catch where I call the api when it drops to the reject operation.

   const cancelStorageTransfer = () => {
      return StorageTransferRequestService.cancelStorageTransfer(selectedStorageTransfer.value.Id)
          .then(() => {
            showSuccess("Transfer İptal İşlemi Başarıyla Gerçekleşti")
            storageTransferRequestSummary()
          }).catch(response => {
            showError(response.data.Information)
          })
    }

I call the api here, but I don't want to use the catch. But when I don't use it, I get "Uncauth(in promise)" error on the log screen.

Here how can I do whether to use the catch at my own will?

about 4 years ago · Juan Pablo Isaza
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!