I've been working on a small Laravel API that should respond when an endpoint is accessed. The issue I'm facing is that while the same endpoint returns data in Postman, it appears empty in Vue Js. I've been trying to figure this out for the past two days, and it's really frustrating me. Any assistance would be greatly appreciated. Thank you.
public function search_passport(Request $request){
$pass = DB::table('passengers')->where('passport_number',$request->input('passport_number'))->get();
if($pass->count() == 0){
return response(['message' => 'Passport number not found, please fill the form']);
}
return new PassengerResource($pass);
}// search_passenger
The above snippet shows the code from the controller in the API
Route::post('/searchpassport', [PassengerController::class, 'search_passport']);
And here is the route being used
this.$http.post('searchpassport', this.passport_number, {headers:{
'Authorization' : 'Bearer ' + this.token.access_token,
'Accept' : 'application/json',
'Content-Type' : 'application'
}})
.then(res => {
console.log(res)
})
This is the API call being made in Vue Js