Reputation: 359
I'm using Angular 8 and the HttpClientJsonpModule. Here's my custom fetch function:
public fetch(): Observable<any> {
// This url has been obfuscated but you get the gist. This is the expected format so I can't alter the string
const url = 'http://exampleurl:6000/GetSomeData(inputParams=@test1)?@test1={hasData=true}';
return this.http.jsonp(url, 'callback')
.pipe(
map(response => {
// always returns null
console.log(response);
})
);
}
When I call this.fetch()
the following error always returns:
JSONP injected script did not invoke callback.
And response
is always null. Am I missing a step somewhere?
Upvotes: 1
Views: 1995
Reputation:
You didn't provide the callback in your request. In the following sample, the query parameter to provide the callback is c (it actually depends on the service). You always need to provide the JSONP_CALLBACK value for such parameter.
const url = 'http://exampleurl:6000/GetSomeData(inputParams=@test1)?callback=JSONP_CALLBACK&@test1={hasData=true}';
Upvotes: 1