我对此非常困惑,似乎找不到任何人报告来自bundle.js的类似问题
基本上我在ec2实例上运行一个react / falcon网站,它正在工作,除了我的网站发布的axios发布到我已设置的烧瓶api。
调用axios post请求的相关代码在我的react.js网页中是:
constructor(props) {
super(props);
console.log('In CONSTRUCTOR');
var postData = {
queryString: this.props.location.search
//queryString: this.props.location.search.split("=")[1]
};
let axiosConfig = {
headers: {
'Content-Type': 'application/json;charset=UTF-8',
"Access-Control-Allow-Origin": "*"
}
};
axios.post('http://172.31.26.109:5000/run_query', postData, axiosConfig)
.then(function (response) {
influencerList = response.data.query_results;
console.log(influencerList);
});
}
以下是页面加载时javascript控制台中的输出:
In CONSTRUCTOR
bundle.js:94878 GRGRGRGRGRGR!!!
bundle.js:94879 ?query=as
bundle.js:94886 DOING AXIOS
bundle.js:94887 {queryString: "?query=as"}
bundle.js:94888 {headers: {…}}
bundle.js:76560 parsing failed SyntaxError: Unexpected token < in JSON at position 0
bundle.js:14474 OPTIONS http://172.31.26.109:5000/run_query net::ERR_CONNECTION_TIMED_OUT
dispatchXhrRequest @ bundle.js:14474
xhrAdapter @ bundle.js:14308
dispatchRequest @ bundle.js:14921
Promise.then (async)
request @ bundle.js:14725
Axios.(anonymous function) @ bundle.js:14745
wrap @ bundle.js:15182
Search @ bundle.js:94889
constructClassInstance @ bundle.js:59072
updateClassComponent @ bundle.js:60556
beginWork @ bundle.js:60942
performUnitOfWork @ bundle.js:62941
workLoop @ bundle.js:63005
callCallback @ bundle.js:53259
invokeGuardedCallbackDev @ bundle.js:53298
invokeGuardedCallback @ bundle.js:53155
renderRoot @ bundle.js:63083
performWorkOnRoot @ bundle.js:63731
performWork @ bundle.js:63684
batchedUpdates @ bundle.js:63803
batchedUpdates @ bundle.js:55047
dispatchEvent @ bundle.js:56138
bundle.js:94895 Error: Network Error
at createError (bundle.js:14847)
at XMLHttpRequest.handleError (bundle.js:14383)
我不知道这里发生了什么,无法找到任何与bundle.js有类似问题的人
谁有任何想法?编辑:
我只是卷曲了这个方法的端点,并且在端点给我的响应的情况下意识到错误是完全合理的:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="http://172.31.26.109:5000/">http://172.31.26.109:5000/</a>. If not click the link.[ec2-user@ip-172-31-26-109 backend]$
显然这是无效的json但是我完全迷失了为什么这会出现在响应中,因为在本地计算机上运行它时不是这种情况。我在卷曲时得到301响应,所以很明显我的重定向或服务器上的某些东西存在问题。想法?