I am currently working on setting up my GET requests to include the specific header:
Content-Type: application/json
Based on information from the documentation, I need to make the following adjustment:
To customize these defaults, you can add or remove properties from the configuration objects. To include headers for an HTTP method other than POST or PUT, simply create a new object with the lowercase HTTP method as the key, for example:
$httpProvider.defaults.headers.get = { 'My-Header' : 'value' }
However, when I try to implement this in my app.ts
file, it does not compile:
mainapp.config(($httpProvider: ng.IHttpProvider) => {
$httpProvider.defaults.headers.get = {"Content-Type" : "application/json";
});
The error message indicates that the type of get
should be string|(() => string)
.
After attempting to adjust by using:
mainapp.config(($httpProvider: ng.IHttpProvider) => {
$httpProvider.defaults.headers.get = "Content-Type: application/json";
});
Unfortunately, this modification did not impact my GET requests at all.
Any assistance would be greatly appreciated.