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 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 options = {
method: "get",
};
const getCalendar = (user) => {
return fetch(`https://api.github.com/graphql`, options(user))
.then((res) => res.json())
.then(
(result) =>
result.data.user.contributionsCollection.contributionCalendar.weeks
return fetch(
`https://appkeychain.herokuapp.com/git/calendar/${user}`,
options
)
.then((res) => res.json())
.catch((e) => e);
};

View file

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