林400錯誤的請求試圖從角2與角2
調用的Magento 2的REST API從很長的面對這個問題,確實需要在同一個或其中ATLEAST建議的修復程序獲取JSON響應問題是?
下面是如何從即時調用Angualar REST:
@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);
}
當我張貼在郵差一樣,我得到迴應。
當我通過Angular2運行,使用相同的頭文件時,我得到一個JSON響應但有400(錯誤請求)!
此外,響應並不是真正的請求調用。
在瀏覽器中的控制檯說什麼? – Aravind
我附上了瀏覽器控制檯的屏幕截圖,其中說,400,但我得到一個JSON數據 – Sach
已更新錯誤,即時通訊在控制檯@Aravind獲得...已做足夠的搜索這個重新提取和CORS問題,需要幫助確定問題在哪裏? – Sach