【发布时间】:2023-03-07 21:15:01
【问题描述】:
我正在运行 k6 测试并为某些代码使用环境变量。我不断收到这个该死的错误:
ReferenceError: 进程未定义
我尝试过使用 __ENV.yadda 在类似问题中建议的替代方案,但没有奏效。
import http from "k6/http";
let formData = {
client_id: "LoadTesting",
grant_type: "blah_blah",
scope: "Scope",
};
const messageHeaders = {
'Content-Type': 'Client Type',
};
let user = null;
export function authorizeUser() {
formData.client_secret = process.env.REACT_APP_CLIENT_SECRET;
if (!user) {
let res = http.post(`https://localhost:44341/connect/token`, formData, { headers: messageHeaders });
if (res.status != 200) {
console.log('res: ', res.status);
throw new Error("couldn't load user");
}
user = JSON.parse(res.body).access_token;
return user;
}
}
我只想让我的环境变量工作!
【问题讨论】:
标签: javascript process environment-variables