I have a function that returns the content of an html file, but it returns something like this:
Promise {<pending>}__proto__: Promise[[PromiseStatus]]: "resolved"[[PromiseValue]]: "<span>contendido</spab>"
How could I get the PromiseValue
to do an innerHTML
I am clear that the promise returns it to me
axios
const template = async(urlGet) => {
const retorno = axios.get(urlGet).then((e) => {
return e.data
})
return await retorno
}
console.log(template('miarchivo.html'))
Try to use the mapping operator:
The key was to add
await
beforeaxios.get()
so I could wait for the promise to have been executed.