为了账号安全,请及时绑定邮箱和手机立即绑定

vue开发中,向服务器请求数据发生跨域,无法得到服务器json数据问题

vue开发中,向服务器请求数据发生跨域,无法得到服务器json数据问题

皈依舞 2018-10-17 17:15:26
问题:在开发一个vue小项目,后台用nodejs搭的,向服务器发送正确的用户名密码会得到一个token,用postman可以正确获得。但是在vue里怎么实现?postman 截图:Vue 的代码如下:结果报错是这样的:XMLHttpRequest cannot load http://localhost:8000/api/aut... Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.Uncaught (in promise) Response {url: "http://localhost:8000/api/authenticate", ok: false, status: 0, statusText: "", headers: Headers…}请问怎么才能做到传一个jsond对象给服务器,然后获取服务器返回的json对象,然后在页面能够获取(渲染)?如果能提供demo或者代码的话,感激不尽。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 1824 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号