B
B
Briss2016-11-17 14:25:14
JavaScript
Briss, 2016-11-17 14:25:14

How to get response.body of request on 400 error and CORS?

There is an application, REST API, symfony 2.8, NGINX.

In some cases, it is required to return a 400 error with a request body that contains errors. In the symphonic apishka interface, everything comes fine, but in my application there is no response.body ...

Is there a way to get the body of an error? Thank you.

$.ajax({
                type: 'POST',
                url: someurl,
                data: data,
            }).done(response => {
                console.log(response);
            }).catch(error => {
                console.log(error);
            })

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2016-11-17
@bingo347

Work with ajax natively, jquery will throw an error on all statuses except 2xx

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question