问题描述
我遇到了问题,因为出现错误“ 未捕获的ReferenceError:未定义进程”。 我想将我的API_KEY添加到文件夹.env中,但是我不能这样做。我的代码如下:(这是 index.js )
$(document).ready(function() {
$("#textButton").click(function() {
var APIkey = process.env.API_KEY; //here I want add my hiding API to variables API_KEY which is in folder .env
const approvalText = $("#textCity").val();
if (approvalText != '') {
$.ajax({
type: 'GET',url: 'https://api.openweathermap.org/data/2.5/weather?q=' + approvalText + "&appid=" + APIkey + '&units=metric',dataType: "json",success: function(data) {
$(".city_name").html(data.name + ',' + data.sys.country);
}
});
} else {
alert("Please write city name on text field");
}
});
});
我已经安装: 节点v12.18.4 -npm 6.14.6 和dotenv
如何解决我的问题?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)