我的api_key位于“ .env”中。我可能会想得太多。这是我目前的代码,可以在不隐藏api_key的情况下运行。从process.env.API_KEY中提取时,我的语法不正确。
function call_api(finishedAPI,ticker) {
request('https://cloud.iexapis.com/stable/stock/' + ticker + '/quote?token= + 'api_key',{ json: true },(err,res,body) => {
if (err) {return console.log(err);}
if (res.statusCode === 200){
finishedAPI(body);
};
});
};
我知道有一种更简单的方法可以做到这一点,而我对Google线索的研究并不是在所有气缸上都触发。我会从星巴克给您买咖啡或番茄罗勒帕尼尼:-)