const fs = require("fs");
const path = require("path");
const propertiesParser = require("properties-parser");
const Octokit = require('@octokit/rest');
let octokit;
let token;
let config;
const file = fs.readFileSync(path.join(process.env.HOME || process.env.USERPROFILE, ".settings"), "utf8");
const props = propertiesParser.parse(file);
config = props.TOKEN;
octokit = new Octokit({
auth: config,
})
上面的代码返回UnhandledPromiseRejectionWarning: HttpError: Bad credentials
我尝试将auth: config
替换为auth: 'actualtokenfromGithub'
并起作用,但是对我来说,为什么这行不通,因为config和'actualtokenfromGithub'均为字符串类型。
const fs = require("fs");
const path = require("path");
const propertiesParser = require("properties-parser");
const Octokit = require('@octokit/rest');
let octokit;
let token;
let config;
const file = fs.readFileSync(path.join(process.env.HOME || process.env.USERPROFILE, ".settings"), "utf8");
const props = propertiesParser.parse(file);
config = props.TOKEN;
octokit = new Octokit({
auth: 'actualtokenfromGithub',
})