Issue
I am making a post request in the following function:
addPlace(title: string,description: string, price: number) {
const newPlace = new Place(Math.random().toString(), title, description, 'https://i.insider.com/5d0150e06fc9200b5a05f042?width=1136&format=jpeg',price, this.authService.userId );
return this.http.post('https://hotelapp-2011f.firebaseio.com/offered-places.json', { ...newPlace, id:null}).subscribe(response => {
console.log(response);
});
But I am getting a 401 Unauthorized error:
HttpErrorResponse {headers: HttpHeaders, status: 401, statusText: "Unauthorized", "https://hotelapp-2011f.firebaseio.com/offered-places.json", ok: false, …}
error: {error: "Permission denied"}
headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
message: "Http failure response for https://hotelapp-2011f.firebaseio.com/offered-places.json: 401 Unauthorized"
name: "HttpErrorResponse"
ok: false
status: 401
statusText: "Unauthorized"
url: "https://hotelapp-2011f.firebaseio.com/offered-places.json"
__proto__: HttpResponseBase
Please help me solve this.
Solution
this is because your server is rejecting your request. probably because of authentication. check your headers that you are sending. are you sending the authentication token correctly? check them all and then try again.
Answered By - MahdiJoon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.