问题描述
我正在使用Vue为wordpress创建一个代码段,以使用同一来源的WordPress网站REST API,它在Codepen上运行完美,可以正确获取数据,但是当我在代码段中添加代码时,它会检索错误。 (此代码在方法内部)
fetchPost: function(){
var myHeaders = new Headers();
myHeaders.append("Authorization","Basic xxxxxxxxxxx");
var requestOptions = {
method: 'GET',headers: myHeaders,redirect: 'follow'
};
fetch("https://example.com/wp-json/wp/v2/posts",requestOptions)
.then((response)=>{
return response.json()
}).then(data => this.posts = data)
.catch(error => console.log('error',error));
}
首先是这个警告:
A cookie associated with a cross-site resource at http://wordpress.com/ was set without the `SameSite` attribute. It has been blocked,as Chrome Now only delivers cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
然后出现此错误:
?v=2.0:6 WebSocket connection to 'wss://public-api.wordpress.com/pinghub/wpcom/me/newest-note-data' Failed: Error during WebSocket handshake: Unexpected response code: 403
g @ ?v=2.0:6
T @ ?v=2.0:6
j @ ?v=2.0:6
关于如何解决它的任何建议?谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)