I have a Python Flask app setup like this:
@app.route("/")
def getlist():
data = jsonify({"test": True, "name": "User",
"teststring": "Hello, World!"})
return data
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5050, debug=True)
Its a very simple one that returns a jsonified dictionary on the root (/
) of domain.
I hosted this site as you can see on localhost:5050
. Now when I use JavaScript to fetch this JSON using the fetch
api like this:
fetch("http://localhost:5050", {
mode: "no-cors", // I added this due to some other error, called cross origin something
})
.then((blob) => blob.json())
.then((data) => console.log(data));
I get this error in this console:
Uncaught (in promise) SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
but the Network tab shows 200 OK