I have a simple html string like '<html><body><h1>hello world!!!!!</h1></body></html>'. I want to convert it to text but I am getting error like .text is not a function
My main purpose is to convert url into html. This is my code
axios({
method: 'get',
url: url,
headers:{
"Content-Type":"text/html"
},
}).then(async (res) => {
const html = await res.data.text();
console.log('html:', html);
}).catch((e) => {
console.log('e: ', e);
})
I consoled res.data and I got html string but I am not able to convert it to text.
I tried to put hardcoded html string to .text() but I am getting the same error that .text is not a function
Is there .text() method ? Why am I getting this error ? Does anybody have other solution ?