所以,我設置了這條路線,它從內部API獲取JSON數據並顯示它。第一次訪問路由時,我得到正確的JSON數據,但是當我刷新頁面時我得到一個錯誤,頁面只是加載。任何想法?
注:我用的請求承諾無法兩次提出請求
app.get('/',function(req,res){
var options = {
//Here I initiate the API call.I actually have a url here.
uri: '',
json: true
};
request(options)
.then(function(data) {
res.json(data);
res.end();
})
.catch(function (err) {
console.log(err);
});
});
*「當我刷新頁面時出現錯誤」* - 這是...? –
HPE_INVALID_CONSTANT.I刪除緩存,現在它的工作原理,但我不知道如何緩存related.I緩存來自API的響應。 – sterg