0

am I returning the correct answer?
I'm trying to return the answer to another file
But I can't get the value out of the function
Am I working with promises correctly?

file:a

const axios = require("axios");

const myPromise = new Promise(function(resolve){
 axios.get(`https://api.exchangerate.host/convert?from=EUR&to=USD&amount=22`).then(function ({data}) {
    resolve(data.result);
   })
   .catch(function (error) {
    resolve();
   })
});
myPromise.then(function(value){

})

module.exports = myPromise

file:b

const myPromise = require("./index");


myPromise.then(function(value){
    console.log(`value: ${value}`);
})
    console.log(`value: ${value}`);
desp200
  • 7
  • 4

0 Answers0