Usm*_*bal 4 http localhost append request angular
刚开始angular2按照heroes教程学习。我正在创建一个请求,URL很好,参数也很好。但是我仍然很困惑为什么http://localhost:4200/要附加我的API通话,并且因此URL完全更改了,并且通话失败了。请对此问题有所了解。我在Google上搜索了很多,但可以找到原因。
我的创建方法
create(user: object): Promise<any> {
return this.http
.post('localhost/usmanProject/api/web/v1/users?access-token=n-EJtZiejtz5RSVWe-U14G4kCnPWMKf0', user, { headers: this.headers })
.toPromise()
.then(res => res.json().data)
.catch(this.handleError);
}
Run Code Online (Sandbox Code Playgroud)
您需要为您的URL添加协议。否则,这是一个相对URL:
.post('http://localhost/usmanProject/api/web/v1/users?access-token=n-EJtZiejtz5RSVWe-U14G4kCnPWMKf0', user, { headers: this.headers })
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2647 次 |
| 最近记录: |