Error: Resource interpreted as Document but transferred with MIME type application/pdf Error: Resource interpreted as Document but transferred with MIME type application/pdf ajax ajax

Error: Resource interpreted as Document but transferred with MIME type application/pdf


In your fetch statement you need to set a header type because the default will be document. Since you have not specified the matching content the browser is letting you know something hooky is happening.

// to stop browser complaining use a request object to specify headervar request = new Request('/pdf', {    headers: new Headers({        'Content-Type': 'application/pdf'    })});fetch(request).then(function() { /* handle response */ });...

Note: This is from my own evaluation research of the fetch api. I have not yet used it in anger so this is untested. I found this site useful https://davidwalsh.name/fetch.

Let me know how you get on please.


Most likely this is because there's a redirect from /pdf and/or there is no file extension.

Add this extra header:

this.set('Content-Disposition', 'attachment; filename=results.pdf');