임에서 휴식 API에 대한 HTTP 요청을 가져올 수 없습니다 HTTP GET 젠토에서 만든 나머지 API를 사용하여 각 2 프론트 엔드의 요청 2.은려고 각 2
VAR \ \ www가 \ HTML \ Angular2 샘플 NG \ 같이 나의 시도는 JSON 응답을 얻을 임 수, JSON 파일 (http://10.20.1.2:3000/data.json)을받을 경우 -http 마스터 \ 웹은 \ 응용 프로그램 \
///<reference path="../node_modules/angular2/typings/browser.d.ts" />
import "rxjs/add/operator/map";
import {Component, Input} from 'angular2/core';
import {Http} from 'angular2/http';
interface Person {
//name: string;
//age: number;
}
@Component({
selector: 'my-app',
template: `<h1>My First Angular 2 App</h1>
<div>{{people | json}}</div>
`
})
export class AppComponent {
@Input() private people: Person[];
constructor(private http: Http) {
}
public ngOnInit() {
this.http.get('http://10.20.1.2:3000/data.json')
.map(response => {
console.log(response.json);
console.log(response.json());
return response.json()
})
.subscribe((items: Person[]) => {
console.log('items: ' + items);
this.people = items;
}, error => console.log(error))
}
}
여기 app.component.ts. 내가이 필요한 것은
내가이 같은 젠토 2의 API 엔드 포인트를 전달해야 내가 이죠 클라이언트에서 호출하는 경우
위의 나머지 엔드 포인트가 완벽하게 작동합니다. 내가 app.component.ts 파일에 동일한 URL (http://10.20.1.2/Magento2/index.php/rest/V1/customers/1)를 사용하는 경우
내가 얻을 :
내가 :(http://10.20.1.2:3000/Magento2/index.php/rest/V1/customers/1으로 포트 3000 URL을 사용하는 경우가) 내가 얻을 :
응답 {_body "/Mage_ang2/index.php/rest/V1/customers/1↵를 얻을 수 없다", 상태 : 404,하는 statusText : "확인"을, 헤더 : 헤더를 입력 : 2 ...
어느 부분이 누락 되었습니까?
당신이 헤더 액세스 제어 - 허용 - 원산지를 설정 했는가를? – giaco