Skip to content

Commit

Permalink
♻️ Use local token in Octokit
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Nov 17, 2020
1 parent 423f157 commit 4a9bb09
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/utils/createOctokit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@ import config from "../data/config.json";
const { apiBaseUrl: baseUrl } = config["status-website"] || {};
const userAgent = config.userAgent;

export const createOctokit = () =>
new Octokit({
export const createOctokit = () => {
let token = "";
if (
typeof window !== "undefined" &&
"localStorage" in window &&
localStorage.getItem("personal-access-token")
)
token = localStorage.getItem("personal-access-token");
return new Octokit({
baseUrl,
userAgent,
auth: token || undefined,
});
};

0 comments on commit 4a9bb09

Please sign in to comment.