I'm having a really tough time fetching HTTP Post data sent from Vue, in my Laravel API.
What I have is extremely simple.
axios({
method: 'post',
url: 'http://localhost:8888/api/vue-data',
data: { firstName: "Dally" },
config: { headers: { 'Content-Type': 'multipart/form-data' }}
})
.then(response => {
console.log(response.data)
})
.catch(e => {
this.errors.push(e)
})
And then the function in my Laravel controller is this...
public function vueData(Request $request)
{
return $request->firstName;
}
The data is being sent as I can see it in Chrome Dev tools but why can't I fetch it in Laravel?
I've tried vue-resource as opposed to Axios but still no luck.
UPDATE #1
So when I use Axios I get the following error.
And when I use vue-resource I get this.
Data is passing...
UPDATE #2
If I change the Laravel controller code to this, I get a response in VueJS. Seems like the controller function in Laravel isn't receiving the Vue data or that I'm accessing it wrong.
public function vueData(Request $request)
{
return "Testing";
}



$request->all()then figure out if there's data keyedfirstNamethere?but why can't I fetch it in Laravel?Well, what's happening? Do you get an error?'multipart/form-data'