From 579ed2bab87fa4e5b18b93a0360f176499229f1e Mon Sep 17 00:00:00 2001 From: JounQin Date: Wed, 15 Jul 2020 20:22:06 +0800 Subject: [PATCH 1/2] chore: remove redundant codes `axios` is Promise based, there is no need to wrap it into a Promise constructor again --- src/utils.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/utils.js b/src/utils.js index 470a9e8..6db120f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -34,17 +34,13 @@ function isValidHexColor(hexColor) { } function request(data) { - return new Promise((resolve, reject) => { - axios({ - url: "https://api.github.com/graphql", - method: "post", - headers: { - Authorization: `bearer ${process.env.GITHUB_TOKEN}`, - }, - data, - }) - .then((response) => resolve(response)) - .catch((error) => reject(error)); + return axios({ + url: "https://api.github.com/graphql", + method: "post", + headers: { + Authorization: `bearer ${process.env.GITHUB_TOKEN}`, + }, + data, }); } From 95f1233ab96ce18f5b538513e02566c76f14f870 Mon Sep 17 00:00:00 2001 From: JounQin Date: Wed, 15 Jul 2020 21:55:04 +0800 Subject: [PATCH 2/2] chore: rebase from master --- src/utils.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/utils.js b/src/utils.js index 364286f..28983b5 100644 --- a/src/utils.js +++ b/src/utils.js @@ -43,13 +43,11 @@ function parseBoolean(value) { } } -function request(data) { +function request(data, headers) { return axios({ url: "https://api.github.com/graphql", method: "post", - headers: { - Authorization: `bearer ${process.env.GITHUB_TOKEN}`, - }, + headers, data, }); }