Saving data in Angular API

0

I need to save a dataset through an API.

I tried to pass the data in different ways but I was not successful. Always gives the error:

  

ERROR Error: Uncaught (in promise): HttpErrorResponse: {"headers": {"normalizedNames": {}, "lazyUpdate": null}, "status": 404, "statusText" url ":

Follow the code below.

//metodo para salvar os dados ao fazer o submit

async onCheck() {
    console.log(this.eventGuest);
    this.eventService.saveInvite(this.events,this.eventGuest);
}


//metodo para fazer a requisição no endpoint

saveInvite(id_events, eventGuest):Promise<any>{
return new Promise((res,rej)=>{
    this.http.post(environment.apiUrl+'api/event/'+id_events+'/invite', eventGuest).then((response)=>{
        res(response);
    }).catch((err)=>{
       rej(err);
    });
}

//caminho da rota da api feita no Laravel

Route::post('/event/{event}/invite','EventController@invite')->middleware('auth:api');
    
asked by anonymous 24.08.2018 / 20:43

1 answer

0

Error 404 'ignorantly' speaking, means that this request did not find an endpoint, ie check that url you are passing, since it is not finding the server.

    
24.08.2018 / 22:53