Http failure response for http://localhost:8000/api/... 500 Internal Server Error in angular 5

Its my component where I am posting data[![Its my service to post the data. and . What's my mistake]2

This API is working fine as I tested using postman. Please help me

1 answer

  • answered 2018-07-11 03:50 Jayraj

    Use this.httpOptions() instead httpOptions, you have to define this.httpOptions() function somewhere and import options from there,

    else try this code, this is suffice for now:

    postMember(Member): Observable<any> {
      return'http://localhost:8000/api/members/store', JSON.stringify(Member), {headers: this.getCommonHeaders()})
          .map(res => res.json())
          .catch(err => Observable.throw(err));
    //function for fetching headers, you can define according to your need over here..
            let headers = new Headers();
            return headers;