I'm trying to store data with axios, but I can't make it..
this is my View
var config = {
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}
};
var app = new Vue({
el: '#app',
data: {
isCardModalActive: false,
name: null,
email: null,
message : 'oi',
video_url: '',
video_title: '',
video_id: '',
username: '',
user_id: '1'
},
methods: {
onSubmit(message) {
axios.post('', {message: 'Test', round: '1', video_id: '31',username: '4' }, config)
.then(function(response){
console.log(response)
});
},
saveName: function(e) {
if(this.name && this.email)
{
var mod = document.getElementById('reg-modal');
mod.className += ' animate-modal';
}
else
{
alert('Please fill up your name and Email');
e.preventDefault();
}
}
}
});
and here my Controller:
$comment = new Comments;
$comment->message = $request->message;
$comment->round = $request->round;
$comment->video_id = $request->video_id;
$guest_name = $request->username;
$comment->user_id = $request->username;
if(!is_numeric($guest_name) && $guest_name != null){
$comment->user_id = -1;
$comment->guest_name = $guest_name;
} else {
}
$comment->save();
return response()->json($comment);
When I click to store the response is {data: {…}, status: 200, statusText: "OK", headers: {…}, config: {…}, …}
But nothing happens, what am I missing?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire