I want to get string value by calling API into Angular. Here is what I am doing Service file -
public getRespondDashboardUrl(): Observable<any> {
return this.http.get(`ref/RespondDashboardUrl`);
}
component file
respondDashboardLink: string;
this.refService.getRespondDashboardUrl().subscribe(result => {
this.respondDashboardLink = result;
});
funcation returns URL as string value https://abcd.xyz.com/Respond/App/index.html#ActionCenter/0
error I am getting
SyntaxError: Unexpected token h in JSON at position 0 at JSON.parse () at XMLHttpRequest.onLoad (http://localhost:4000/vendor.js:33488:51) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (http://localhost:4000/polyfills.js:8108:31) at Object.onInvokeTask (http://localhost:4000/vendor.js:78969:33) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (http://localhost:4000/polyfills.js:8107:60) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (http://localhost:4000/polyfills.js:7880:47) at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (http://localhost:4000/polyfills.js:8183:34) at invokeTask (http://localhost:4000/polyfills.js:9429:14) at XMLHttpRequest.globalZoneAwareCallback (http://localhost:4000/polyfills.js:9466:21)
If you response type is string. more type check responseType.
this.http.get(`ref/RespondDashboardUrl`, {responseType: 'text'})
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