add_product(token: string,data:any): Observable<any> {
return this.http.post<any>(`${API_USERS_URL}/products/create`, {
headers: {
'Authorization': 'Bearer ' token,
},
body: JSON.stringify(data),
});
}
CodePudding user response:
** Try **
return this.http.post<any>(`${API_USERS_URL}/products/create`,data, {
headers: {
'Authorization': 'Bearer ' token,
}
});
CodePudding user response:
First you have see on your back-end may be CORS error are there, if CORS is enable, disable it and then try it. also try with this code.
httpOptions = { headers: new HttpHeaders({'Content-Type': 'application/json', 'Authorization': 'Bearer ' 'token'}) };
constructor(private httpClient: HttpClient) { };
getData(): Observable<string> {
return this.httpClient.post<string>(Constant.BASE_URL "UserReaction/deleteUserReaction", { "data": { 'userReactionId': 'userReactionId' } }, this.httpOptions).pipe(retry(3), catchError(Constant.handleError));
}