From 5f5008988ad20b4ec1eacc3cf086c3a157164e3d Mon Sep 17 00:00:00 2001 From: Lioness100 Date: Sat, 27 Mar 2021 11:45:18 -0400 Subject: [PATCH] Simplify usage of promises --- index.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index d62a146..4b1fea9 100644 --- a/index.js +++ b/index.js @@ -1,17 +1,11 @@ const axios = require("axios"); const fact = { - async getFact() { - return new Promise(async (resolve, reject) => { - await axios - .get(`https://animu.ml/fact`) - .then(function (response) { - resolve(response.data); - }) - .catch((err) => { - return reject(err); - }); - }); + getFact() { + return axios + .get(`https://animu.ml/fact`) + .then((response) => response.data) }, }; + module.exports = fact;