I am fetching the PDF via URL, and want to check does that URL will return the document successfully.
Sending a request via
fetch()
Get a
response.text()
Want to check does text exist
Text is always empty
Cannot figure out why?
response.text()
always returns empty text, even when PDF document exist in response.
const handleOpenPDF = (url: any) => {
fetch(url, {
method: 'GET',
mode: 'no-cors',
})
.then(res => res.text())
.then(text => {
enter code here
// TEXT is always empty event when response is good
console.warn('text', text);
window.open(url, '_blank');
})
.catch(err => {
console.warn('Error', err);
});
};