Get the PromiseValue of a promise

1

I have a function that returns the contents of an html file, but it returns something like this:

Promise {<pending>}__proto__: Promise[[PromiseStatus]]: "resolved"[[PromiseValue]]: "<span>contendido</spab>"

How could I get PromiseValue to do an innerHTML

  

I am clear that the promise returns 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'))
    
asked by Merling Samuel Sobalvarro 17.01.2018 в 17:49
source

1 answer

1

Try to use the mapping operator:

const template = async(urlGet) => {
  const retorno = axios.get(urlGet).map((e) => {
    return e.data
  })
  return await retorno
}

console.log(template('miarchivo.html'))
    
answered by 17.01.2018 в 18:49