Answer the question
In order to leave comments, you need to log in
How to check on the side of the api method whether the user is authorized if the request goes through ajax in Laravel?
Sample code:
$.ajax({
async: true,
cache: false,
type: "POST",
url: url,
dataType: "html",
ifModified: true,
timeout: 10000,
success: function (data) {
},
dataFilter: function (data, type) {
serverData = JSON.parse(data);
console.log(serverData);
}
});
public function like_to_api($type, $id, $value)
{
return [Auth::id()];
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question