M
M
Mikhail Smirnov2018-07-08 21:59:27
Vue.js
Mikhail Smirnov, 2018-07-08 21:59:27

How to send post data json to another domain in vue axios?

Good evening!
I am rewriting one project from jquery to vuejs,
more precisely Yii2 + vuejs
Faced one problem
When transferring json data to another domain (api service), it gives an error:
Request header field X-CSRF-TOKEN is not allowed by Access-Control-Allow-Headers in preflight response.
Code example:

axios.post('http://test.local/api.php?action=order-save', {
                    data: data
                })
                    .then(response => {
                        if (response.data.success) {
                            
                        }
                    })
                    .catch(error => {
                       
                    })

with $.ajax the data was passed to the Form Data, but here the Form Data is not passed
Tell me what could be the problem

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question