Saving data in Angular API

Asked

Viewed 75 times

0

I need to save a data set through an API.

I tried to pass the data in several ways but did not succeed. Always gives the error:

ERROR Error: Uncaught (in Promise): Httperrorresponse: {"headers":{"normalizedNames":{},"lazyUpdate":null},"status":404,"statusText":"Not Found","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');
  • Status 404 means route not found. Check your URL.

1 answer

0


The error 404 'ignorantly' speaking, means that this request did not find an endpoint, IE, check this url you are passing, because it is not finding the server.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.