axios post request to send form data

You can post axios data by using FormData() like: var bodyFormData = new FormData(); And then add the fields to the form you want to send: bodyFormData.append(‘userName’, ‘Fred’); If you are uploading images, you may want to use .append bodyFormData.append(‘image’, imageFile); And then you can use axios post method (You can amend it accordingly) axios({ … Read more

How to set header and options in axios?

There are several ways to do this: For a single request: let config = { headers: { header1: value, } } let data = { ‘HTTP_CONTENT_LANGUAGE’: self.language } axios.post(URL, data, config).then(…) For setting default global config: axios.defaults.headers.post[‘header1’] = ‘value’ // for POST requests axios.defaults.headers.common[‘header1’] = ‘value’ // for all requests For setting as default on … Read more

How can I get the status code from an HTTP error in Axios?

What you see is the string returned by the toString method of the error object. (error is not a string.) If a response has been received from the server, the error object will contain the response property: axios.get(‘/foo’) .catch(function (error) { if (error.response) { console.log(error.response.data); console.log(error.response.status); console.log(error.response.headers); } });

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)