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

159
Views
Retry axios request when response is empty
  await axios
    .post(
      executeBatch,
      {
        headers: {
          "Content-Type": "application/json",
          "x-access-token": localStorage.getItem("token"),
        },
      }
    )
    .then(
      (response) =>
        this.$store.commit(
          "insertOutputFile",
          response.data.outputFile._id
        ),
    );

  alert("You can download the result");

so sometimes i get empty response with status code 200, was thinking about retrying the request if that happens, am wondering what is the correct way to approach this issue.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think axios interceptors will work for you.

axios.interceptors.response.use((response) => {
    return response
  },
  async function(error) {
    const originalRequest = error.config;

    if () { // condition
      originalRequest._retry = true;
    }
  }
)

You can create setupAxios file in your base redux directory and export it from index.js in your base redux directory.

export {default as setupAxios} from "./setupAxios";

And define setupAxios from your root index.js file

import * as _redux from "./redux";

_redux.setupAxios(axios, store);

Btw, I am using react.js, it could be a little different in vue.js.

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!