From 5926a874c21a83a85360b8b3996e53c8e7a141ce Mon Sep 17 00:00:00 2001 From: Raunak Gurud Date: Wed, 31 Jan 2024 11:46:42 +0530 Subject: [PATCH] refactor: #12 --- dist/index.js | 10 ++++++++-- src/constants.ts | 2 +- src/controller/index.ts | 4 ++++ src/libs/axios.ts | 5 ++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 4b9c9b8..01b039e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.HASHNODE_ENDPOINT = void 0; -exports.HASHNODE_ENDPOINT = "https://gql.hashnode.com/"; +exports.HASHNODE_ENDPOINT = "https://gql.hashnode.com"; /***/ }), @@ -191,6 +191,9 @@ const getUser = async () => { } }; exports.getUser = getUser; +(async () => { + console.log(await (0, exports.getUser)()); +})(); /***/ }), @@ -301,7 +304,10 @@ const axios_1 = __importDefault(__nccwpck_require__(8757)); const constants_1 = __nccwpck_require__(5105); const api = axios_1.default.create({ baseURL: constants_1.HASHNODE_ENDPOINT, - headers: { Authorization: `${process.env.HASHNODE_KEY}` }, + headers: { + "Content-Type": "application/json", + Authorization: `${process.env.HASHNODE_KEY}`, + }, }); exports.api = api; diff --git a/src/constants.ts b/src/constants.ts index d702de5..1c2c313 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1 +1 @@ -export const HASHNODE_ENDPOINT = "https://gql.hashnode.com/"; +export const HASHNODE_ENDPOINT = "https://gql.hashnode.com"; diff --git a/src/controller/index.ts b/src/controller/index.ts index 9e55920..fb22c83 100644 --- a/src/controller/index.ts +++ b/src/controller/index.ts @@ -206,3 +206,7 @@ export const getUser = async (): Promise => { }; } }; + +(async () => { + console.log(await getUser()); +})(); diff --git a/src/libs/axios.ts b/src/libs/axios.ts index c4a730f..d90dfee 100644 --- a/src/libs/axios.ts +++ b/src/libs/axios.ts @@ -3,7 +3,10 @@ import { HASHNODE_ENDPOINT } from "../constants"; const api = axios.create({ baseURL: HASHNODE_ENDPOINT, - headers: { Authorization: `${process.env.HASHNODE_KEY}` }, + headers: { + "Content-Type": "application/json", + Authorization: `${process.env.HASHNODE_KEY}`, + }, }); export { api };