I want to add to my application a configuration JSON file.
I've added it to my project and tried to get it using $http.get:
$http.get('http://localhost/myProject/content.json').success(function (data) {
// Do stuff...
}).error((data, status, headers, config) => {
// Failure...
});
The problem is that every time I get an error 404.
This is an issue with your web server mime type configuration - it has none for json, probably. Try renaming the file extension to .txt or .html and it should work.
You can also add the mime type extension to the server. For IIS express, it's web.config. For example:
<staticContent>
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With