2

What's the best way to retry failed AJAX request in VueJS ?

bulkDecline(requests, decliner) {
  requests = _.map(requests, 'id');
  return Vue.http.post(`${baseUrl}/api/decline/${decliner}/bulk-decline`, requests)
    .then(
      (response) => {
        Notification({
          title: 'Success!',
          message: response.data.message,
          type: 'success'
        });
        return response;
      }, 
      (response) => {
        this.bulkDecline(requests, decliner);
      }
    );
}

But it seems like its not working.

darryn.ten
  • 6,784
  • 3
  • 47
  • 65
Monkey D Naruto
  • 176
  • 2
  • 8

1 Answers1

0

Are you doing this within a single-file component?

If so, have you tried using

this.$http.post

instead of Vue.http.post?

You may also have some luck if you send through your requests in an object like { data: requests } or similar.

return this.$http.post(`${baseUrl}/api/decline/${decliner}/bulk-decline`, { data: requests })
darryn.ten
  • 6,784
  • 3
  • 47
  • 65