I am trying to fetch data from http getUrl function but unable to set the header in request.
var response = http.getUrl(url,{format:'json'});
In response I am getting data in Content-Type text/html; charset=utf-8
I need to set header content-type:"application/json" to get in correct format but there is no way to set header in get call.
Please help me to resolve this small issue.
Thanks in advance.
I resolved the issue, we can add headers in options object and pass as an argument
in getUrl function
var options = {
format: 'json',
query: {
term: type
},
headers:{'Accept':'application/json'}
};
var response = http.getUrl(config.get('remote.url') + '/search', options);