When I try to send content of textarea with axios, the request received by Laravel is empty.
axios.defaults.headers.common = {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN' : document.querySelector('meta[name="csrf-token"]').getAttribute('content')
};
async sendMessage(e) {
if (e.shiftKey === false) {
this.errors = {};
e.preventDefault();
let response = await axios.post('/api/conversations/' + this.$route.params.id, {
content: this.content,
});
}
}
Route::post('/conversations/{user}', 'API\ConversationsController@store')->middleware('can:talkTo,user');
public function store(Request $request, User $user) {
return ['request' => $request, 'user' => $user];
}
Result in browser :
request: {attributes: {}, request: {}, query: {}, server: {}, files: {}, cookies: {}, headers: {}}
user: {id: 2, name: "JohnDoe1", email: "john1@doe.fr", email_verified_at: null, created_at: null,…}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2OFn0Dg
via IFTTT
Aucun commentaire:
Enregistrer un commentaire