mercredi 6 novembre 2019

404 when using a variable in URL- error: No query results for model [App\Models\Seeker]

Im calling from the angular front side to my laravel back end. When I use a variable in the url (USERID) it gives me a 404 error.

When I remove the USERID from the url it works and reach the function in the server.

Client side:

  getSeeker(userID: number) {
    return this.http.get(`${this.endPoint}/${userID}/getSeekerProfile`, 
      {headers: this.getTokenHeaders()})
  }

Server side:

    Route::get('candidate/{userID}/getSeekerProfile',   'CandidateController@getSeekerProfile');

Error on client side:

GET http://localhost:8000/api/headhunter/candidate/363/getSeekerProfile 404 (Not Found)

Error on server side:

message: "No query results for model [App\Models\Seeker]."

the targted function (getSeekerProfile): PS - i also tried to just return dd('reached') and removing the (User $userID) parameter.

    public function getSeekerProfile(User $userID)
    {
        dd($userID);
    }

I cant really find the problem. Im not even using the Seeker model in relation to this piece of code.

Any ideas will be most welcome.

Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire