0

I`ve a code like this:

on getImage.js file it calls a API and get some data from it:

const fetch = require("node-fetch");
const url = "api.something.example"

const getImage = async url => {
    try {
        const response = await fetch(url)
        const json =  await response.json()
        console.log(json)
        return json
    }
    catch(error){
        console.log(error)
    }
}

module.exports = getImage(url)

and then on index.js it calls the previous file and expects for the object that comes from the API

const getImage = require("./getImage")
console.log(getImage)

But what prints on the console it is: Promise { } There is a simple way to get the object data?

Gabriel
  • 79
  • 8

0 Answers0