Getting JSON.parse Syntax error although status: 200 (ok)

Hi, I’m using fetch() to GET my JSON file from another codepen. It was working perfectly yesterday. The URL includes https and the response info shows a status of 200/OK. I’ve read about cors but I still cannot figure out this issue. Help please! Thanks!

Pen link: https://codepen.io/CodeMoo/pen/RvQKjX?editors=0111

Code (starting at JS 4):

const url = "https://codepen.io/CodeMoo/pen/KJEmeO.js";

fetch(url)
	.then(response => response.json())
	.then(data => {
		quotes = data;
	})
	.catch(error => console.log("error: " + error));

Error out: “error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data”

It’s because your requested .js file is not a valid JSON.

Check it here: https://jsonlint.com/

I figured it out. I ran Tidy JS and it removed all the “” from quote and author, thus ruining my JSON.

I didn’t know that this existed, awesome! Thanks.

After fixing the changes from JS Tidy, it still doesn’t work. This code worked yesterday with the .js fetch. I’ll keep digging.

Or you could just use jsonbin.io

Yea, I just switched to using http://myjson.com/. I had seen another pen that used codepen to host the json in a separate pen but I’m tired of wrestling with it. Thanks for your replies!