Goodreads Developers discussion
Callback MIME type confusion.
date
newest »


I added scriptTag.type = "type='application/json'" in there and I don't get the error anymore.
The result you are getting from the API is a json, not a js file; that's why you need to explicitly set the type of the response.

I was super excited because the error went away!
But... then I realized I was no longer getting an error because it was no longer actually _loading_ the remote file. That is to say, no network request was made for the file.
For reasons I do not understand, the file does not load when setting the type.
Using the setAttribute() method leads to an identical-_looking_ code, but one in which the jsonp is retrieved... but then blocked because of the mime type error.
Did you have it working in a fiddle or something?
Thanks!
Sam
I've used the xml flavor of the goodreads API in php casually for a number of years now, but I was trying out some JS-based stuff as listed in the docs and... I can't figure out the specific way in which I'm being stupid.
So... I need your help in telling me just how stupid I am. Because clearly I am doing something stupid.
I'm trying to access review_counts via the callback method.
- The request returns the result I want, formatted as a function.
- The code is putting the script tag in the header correctly.
- The browser throws an error saying "Refused to execute script from [Goodreads] because its MIME type ('js') is not executable, and strict MIME type checking is enabled."
- Indeed, Goodreads does appear to be delivering the file with that MIME type.
- I have tried setting the attributes on the head tag via setAttribute() to no avail.
You can C&P the following into codepen or whatever and experience the same thing I am:
function myCallback(result) {
console.log(result);
}
var scriptTag = document.createElement('script');
scriptTag.src = "https://www.goodreads.com/book/review...
document.getElementsByTagName('head')[0].appendChild(scriptTag);
... yep.
If anyone could point me to the way, the truth, and the light, that would be swell.
Thank you!
- S