Axios post response is html

Asked By: Anonymous

Good morning all,

i use: “laravel/framework”: “^6.2”,
“axios”: “^0.19”,
“vue”: “^2.5.17”,

I have a problem when I use a axios.put and route put my response.data is right (response.data: “ok”) but in my axios.post and route post I receive an html in my response.data and I do not understand why someone can explain me please? and how to get an reponse.data:”ok” in my axios.post?

file .vue

let formData = new FormData();
                formData.append('connexion', this.customer);
                formData.append('product', this.product);

                axios.post('hosting/', formData)
                    .then(response=> {
                        console.log(response);
                    });

file route

Route::post('hosting', ['uses' => '[email protected]']);

file controller

public function cart(Request $request)
{
    return 'ok';
}

my response when axios.post

my response when post

my response when axios.put

my response when put

thank’s all for your help!


Solution

Answered By: Anonymous

[UPDATE] I have finally resolved this issue by just remove “/” on my url POST

The reason of the POST which sent me an html message is that in the POST if the “/” it waits for something params then while in PUT it removes the “/” automatically because no params behind!

axios.post('hosting', formData)
      .then(response=> {
              console.log(response);
            });

really a silly mistake sorry. I put the answer to help other people.

techinplanet staff

techinplanet staff


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno