Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodejs架设中间件,请求https://www.pwxcoo.com/dictionary返回空数据 #15

Closed
xizhouhezai opened this issue Aug 27, 2018 · 5 comments

Comments

@xizhouhezai
Copy link

想做一个简单的前端页面,来显示查询结果,但是发生跨域问题,于是想用nodejs做个中间件,解决跨域问题,但是在用nodejs的http请求https://www.pwxcoo.com/dictionary这个接口时,返回的数据总是为空,在浏览器打开接口和在postman里测试这个接口都没问题,为什么在nodejs里请求会返回空数据?希望大佬解答一下,谢谢了

@pwxcoo
Copy link
Owner

pwxcoo commented Aug 27, 2018

  • 跨域是因为我确实没做跨域的配置。。
  • node 里返回的 HTTP 状态码是什么?

@xizhouhezai
Copy link
Author

400,显示是成功返回,但是就是没有数据,是个空数组

@pwxcoo
Copy link
Owner

pwxcoo commented Aug 31, 2018

不不不,400 是无效请求,可能的原因是:

  • 不是 GETPOST
  • 没传参数

@xizhouhezai
Copy link
Author

不好意思,打错了,是200

@pwxcoo
Copy link
Owner

pwxcoo commented Aug 31, 2018

这我也不知道了。。Postman 里可以的话,说明 http 是正常的,可能是你的 node 代码有问题,你可以再看看

@pwxcoo pwxcoo closed this as completed Dec 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants