In vue/cli 4 / vuejs 2.6.10 / vuex,3.0.1 app I make axios request
axios.get(apiUrl + '/personal/user_groups/'+user_id ) /
.then((response) => {
to backend app(Laravel 5/jwt-auth) with routes in jwt.auth group :
Route::group(['middleware' => 'jwt.auth', 'prefix' => 'personal', 'as' => 'personal.'], function ($router) {
Route::post('user_groups', 'API\PersonalController@user_groups');
and got error :
"error":"UNAUTHORIZED_REQUEST"
I found a way of sending POST request with config parameter and token parameter, which I got on successfull login:
let config = {
withCredentials:true,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
}
}
axios({ url: apiUrl + '/personal/user_groups', data: {user_id:user_id, token: this.getters.token}, method: 'POST', config : config })
.then(response => {
But if there is a way to send GET request and I made in the topic start ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire