Closed ihorml closed 7 years ago
I don't believe that our docs are incorrect.
Here is just one of my working examples.
export const client = axios.create({
baseURL: config[ KEY ],
withCredentials: true,
headers: {
'ws-api': '2.1',
'Content-Type': 'application/x-www-form-urlencoded'
},
transformRequest: [ function (data) {
var str = []
for (let p in data)
if (data.hasOwnProperty(p) && data[ p ] != null) {
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(data[ p ]))
}
return str.join('&')
} ]
})
Notice the axios configuration parameters are not nexted inside of the options.
Are you trying to configure multiple clients using this?
@nmaves I'm talking about JSON requests (responseType:json
, contentType: application/json;charset=utf-8
) when you receive an error and handle it by .catch like:
someReduxAxiosAction().then((response) => {
}).catch((err) => {
});
On this way you receive error I noticed on Topic. If it's matter I can provide you an example a little bit later.
Are you setting returnRejectedPromiseOnError to true?
@nmaves yes. I'll try setup an example for you
Please update your README from this one:
To this one:
As I see from this line you use options for Axios from
client.options
. So If I would like to useresponseType
:json
I should put it topayload.options
orclient.options
.I just spent a lot of time on investigating why I receive the following error:
So the solution was just simple - put responseType:
json
toclient.options
.