config for 3rd party calendar fetch

This commit is contained in:
sorrelbri 2020-05-26 10:37:29 -07:00
parent d5400b1a53
commit ef681da60b
2 changed files with 7 additions and 36 deletions

View file

@ -1,38 +1,13 @@
const token = process.env.API_TOKEN; const options = {
method: "get",
const query = (user) => `query { };
user (login: "${user}") {
contributionsCollection {
contributionCalendar {
weeks {
contributionDays {
contributionCount
}
}
}
}
}
}`;
const options = (user) => ({
method: "post",
headers: {
"Content-Type": "application/json",
Authorization: `bearer ${token}`,
},
body: JSON.stringify({
query: query(user),
}),
});
const getCalendar = (user) => { const getCalendar = (user) => {
return fetch(`https://api.github.com/graphql`, options(user)) return fetch(
`https://appkeychain.herokuapp.com/git/calendar/${user}`,
options
)
.then((res) => res.json()) .then((res) => res.json())
.then(
(result) =>
result.data.user.contributionsCollection.contributionCalendar.weeks
)
.catch((e) => e); .catch((e) => e);
}; };

View file

@ -1,7 +1,6 @@
const path = require("path"); const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin"); const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin"); const HtmlWebpackPlugin = require("html-webpack-plugin");
const { DefinePlugin } = require("webpack");
module.exports = { module.exports = {
entry: { entry: {
@ -13,9 +12,6 @@ module.exports = {
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: "index.html", template: "index.html",
}), }),
new DefinePlugin({
"process.env.API_TOKEN": JSON.stringify(process.env.API_TOKEN),
}),
], ],
output: { output: {
filename: "[name].bundle.js", filename: "[name].bundle.js",