【发布时间】:2018-01-26 17:03:40
【问题描述】:
我正在尝试从我的 Angular Web 应用程序上传foursquare 用户的个人资料照片。我正在使用“用户/更新”端点 - https://developer.foursquare.com/docs/users/update
这是我的模板,
<input type="file" (change)="fileChange($event)" placeholder="Upload file">
这是我的组件代码,
fileChange(event) {
let fd:FormData=new FormData();
fd.append("photo",event.target.files[0]);
let headers=new Headers();
headers.append("Content-Type","multipart/form-data");
headers.append("Accept","application/json");
headers.append("Access-Control-Allow-Origin","true");
let options=new RequestOptions({headers:headers});
this.http.post("https://api.foursquare.com/v2/users/self/update?oauth_token=myauthtoken&v=20160108",fd,options)
.map(response=>response.json())
.subscribe(
data=>console.log(data),
error=>console.log(error)
);
}
我收到 405 (Method Not Allowed) 和 Response for preflight has invalid HTTP status code 405 在控制台中出现错误。
【问题讨论】:
标签: angular cors foursquare angular-http http-status-code-405