question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Form goes to catch on 200 response

See original GitHub issue

Hello,

Probably yet another stupid question 😄

I’m able to validate and display the errors on the form. However, after fixing the errors (entering the fields), and re-submitting the form, it still goes into the catch callback. Yet in the network tab I see a 200 ok reponse from laravel. And my resource is created correctly in the database.

I’m not sure why it doesn’t go into the then callback.

this.form.post(route('api.page.page.store'))
    .then(response => {
        this.loading = false;
        vm.$message({
            type: 'success',
            message: response.data.message
        });
        window.location = route('admin.page.page.index');
    })
    .catch(error => {
        this.loading = false;
        vm.$notify.error({
            title: 'Error',
            message: 'There are some errors in the form.'
        });
    });

Is there something else to do?

Thanks

Edit: even when entering the form correctly from the first time, ie it never went into the catch callback, it stills goes into it, even though laravel returns a 200.

Edit: here is the full onSubmit method called.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
sebastiandedeynecommented, Sep 14, 2017
  vm.$message({
      type: 'success',
-     message: response.data.message
  });

response.data doesn’t exist here, causing an error. catch is called when anything in the then chain goes wrong, not just when there’s an error in the promise itself.

0reactions
nWidartcommented, Sep 14, 2017

oh man, thanks! I didn’t know that catch also catches errors in then. 😄

I expected message: response.data.message because another component (a delete component) does has that structure. Curious here it’s just response.message instead.

Thanks a lot for the help! 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I navigate once I submit a form and receive a status of ...
I am expecting to have it navigate to the root route when I get a status 200 from the server, which I am...
Read more >
200 OK - HTTP - MDN Web Docs
The HTTP 200 OK success status response code indicates that the request has succeeded. A 200 response is cacheable by default.
Read more >
Microsoft forms shows error no of responses exceeded when ...
Microsoft forms shows error no of responses exceeded when reaches 200 ... get 1000 responses per form and now when it reaches 200...
Read more >
HTTP Status Code 200: What Is the 200 "OK" Response?
An HTTP status code 200 means success. The client has requested documents from the server. The server has replied to the client and...
Read more >
How to catch HTTP Client connector status code and errors ...
I am trying to do error handling against an HTTP Client Connector using a Try/Catch shape and a notify Shape.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found