我在Axios的React中进行了两次API调用。在我的本地服务器中,两个调用都会出现,在部署到Netify之后,只会出现第一个API调用。我不知道是什么导致了它,但我没有错误消息。右图是部署后的镜像,左图是本地服务器上的镜像。我XXXed我的钥匙,这样它就不会出现在代码中
import axios from 'axios';
const API_URL = 'https://newsapi.org/v2/top-headlines?sources=techcrunch&apiKey=XXXX';
const API_URL2= 'http://newsapi.org/v2/top-headlines?sources=ars-technica&apiKey=XXXX';
export const getNews = async () => {
const result = await axios.get(API_URL)
.then(response => {
return response.data.articles;
});
return(result);
}
export const getNews2 = async () => {
const result = await axios.get(API_URL2)
.then(response => {
console.log(response.data)
return response.data.articles;
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});
return(result);
发布于 2019-12-27 06:37:53
为什么第一个是https,第二个是http?
https://stackoverflow.com/questions/59494121
复制相似问题