我正在尝试制作脚本来为集合生成我的身份验证承载令牌。所以我不必每次都传递令牌,我会从父母那里继承身份验证。但我不知道我在脚本中哪里错了,我无法生成令牌并且它给了我错误
There was an error in evaluating the Pre-request Script: Error: No data, empty input at 1:1 ^
这是我的脚本,
var expiresOn = pm.variables.get('ExpiresOn');
if (!expiresOn || new Date(expiresOn) <= new Date()) {
var clientId = '565v7677676vfdrd';
var apiToken = '6565fdvdrdfd';
var request = {
url: 'http://.../auth/token',
method: 'POST',
header: 'Content-Type:application/Json',
body: {
mode: 'application/json',
raw: clientId + apiToken
}
};
}
};
pm.sendRequest(request, function (err, res) {
if (res !== null) {
var json = res.json();
pm.environment.set('Access_Token', json.access_token)
var expiresOn = new Date(0);
expiresOn.setUTCSeconds(json.expires_on);
pm.environment.set('ExpiresOn', expiresOn);
}
});
}