2017-09-17 47 views
0

但它返回-403为什么 enter image description here有毛病JSONP数据,如何获取数据

但是当我点击的是,它配备了这个 enter image description here 我怎样才能得到的消息

+0

确实无名资源实际上是否支持JSONP?你知道403错误是什么吗? –

+0

将您的代码作为文本提供,而不是图像。 – Ouroborus

+0

导出函数getShows(){ const url ='https://api.bilibili.com/x/web-show/res/loc?' 常数数据= Object.assign({},{JSONP: 'JSONP'},{ PF:7, ID:1695 }) 返回JSONP(URL,数据,{PARAM: 'jsonpCallback'}) } –

回答

0

The HTTP 403 Forbidden client error status response code indicates that the server understood the request but refuses to authorize it. 。在使用Fetch API进行单行检查后,答案是:服务器不处理跨源资源共享 - 使得跨源AJAX不可行。您可以通过使用简单的本地HTTP服务器(例如Python)从服务器获取数据(例如请求)并自行提供数据(例如使用Flask)来避免它。 在JS控制台中检查:

fetch('https://api.bilibili.com/x/web-show/res/loc?jsonp=jsonp&pf=7&id=1695').then(r=>r.json()).then(json=>console.log(json))