文章详情页
angular.js - angular4 发出post请求 服务端显示OPTIONS
浏览:344日期:2024-09-14 10:17:57
问题描述
private headers = new Headers({’Content-Type’: ’application/json’});
private url = ’localhost:3000/users/register’; constructor(private http: Http) { }registerEmail(link:string , email: string , password: string): Promise<any> {return this.http .post(this.url, JSON.stringify({email: email , password: password}), {headers: this.headers}) .toPromise() .then(res => res.json().data) .catch(this.handleError);}

用postman请求正常显示post请求
问题解答
回答1:你运行POST请求的主机是什么?angular在跨域请求的时候会有一个Options,好像是检查是否允许跨域的。我目前的项目里前后端域名不一样的,也是Options和Request同时出现,以前同域名的时候没有。
相关文章:
1. 问题Unknown column ’’ in ’where clause’2. angular.js - 如何控制ngrepeat输出的个数3. html - vue项目中用到了elementUI问题4. javascript - 在使用 vue.js element ui的时候 怎么样保留table翻页后check的值?5. mysql_replication - mysql读写分离时如果单台写库也无法满足性能怎么解决6. javascript - vue组件通过eventBus通信时,报错a.$on is not a function7. css3 - css怎么实现图片环绕的效果8. linux - ubuntu 命令行中文 显示菱形,期望通过引入字体解决而不是zhcon这种方式9. ionic 项目 ionic build android -release 打包时报错10. python - 如何用pandas处理分钟数据变成小时线?
排行榜

网公网安备