config for 3rd party calendar fetch
This commit is contained in:
parent
d5400b1a53
commit
ef681da60b
2 changed files with 7 additions and 36 deletions
|
@ -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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Loading…
Reference in a new issue