我已经尝试过Stack Overflow的一些解决方案,但仍然无法解决。需要其他解决方案。
componentDidMount(){
this.getCar()
}
async getCar() {
try {
const response = await axios.get('http://127.0.0.1:8000/topratedcars');
console.log(response);
} catch (error) {
console.error(error);
}
}
答案 0 :(得分:0)
您好,我想您可以尝试使用ngrok之类的服务将本地主机暴露于Internet,该服务将为您生成一个url,然后尝试使用该url从您的代码发送请求。只需下载并按照此处的说明进行操作:https://ngrok.com/docs