Here is an example of a .json
file:
[
{
"name":"Jon Skeets"
},
{
"name":"Bill Joy"
}
]
If this json file is obtained as:
$http.jsonp(pathToFile).then() {
...
}
It returns a 404. There is nothing wrong with pathToFile
I have verified it with curl, wget and the browser
. But the problem is with jsonp()
having to fetch .json
files with the above structure. $http.get()
can parse .json
files with the above structure. But JSONP
cant. It needs a dictionary at the top level and not an array.
To demonstrate this, I have created this firebase: https://blazing-fire-6512.firebaseapp.com/name.json
fetch the link in your browser or wget and it works. Try fetching it with Angular here and it returns 404 Request failed.