Khandaker Toihidul Islam
Front-end Developer
React Js | Javascript | HTML | CSS | Bootstrap | Wordpress | PHP | Mysql

Axios sent OPTIONS request instead of POST method

Axios uses JSON as the default content type, the call was always going with a browser as a OPTIONS call not a POST method. To overcome, we need to set the ‘Content-Type’ correctly. My configuration as following

        let config={
            headers: {'Content-Type' : 'application/x-www-form-urlencoded'}
        }
        return axios.post(postUrl,postJson,config).then(response=>{
             return response.data;
         }).catch(error=>{
             return error;
         });

You may also like...

Leave a Reply