Getting JSON response with 400 bad request in Angular 2 -


im trying call rest api of magento 2 angular 2.

facing issue long , need fix on same or atleast suggestion on issue is?

below how im calling rest angualar:

@injectable() export class productservice { public _producturl = 'http://10..../mage_ang2/index.php/rest/v1/customers/1';  constructor(private _http: http) { }  getproducts(): observable<iproduct[]> { let headers = new headers({ 'content-type': 'application/json; charset=utf-8' }); headers.append('authorization', 'bearer ntthnrbj1uam2tuv1ekva7n8jh18mcnkby3'); let options = new requestoptions( {method: requestmethod.get, headers: headers });   console.log(headers);     return this._http.get(this._producturl,options)         .map((response: response) => <iproduct[]> response.json())         .do(data => console.log('all: ' +  json.stringify(data)))         .catch(this.handleerror); } 

when post same in postman, response.

when run through angular2, same headers, json response 400 (bad request) !

also response doesnt come actual request call.

enter image description here

enter image description here

try this, should work

 let headers = new headers({         'content-type': 'application/json',         'authorization':'bearer ntthnrbj1uam2tuv1ekva7n8jh18mcnkby3'     });   return this._http.get(url,{headers:headers})         .map(response: => {             return response.json();         }); 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -