loading...
Cover image for NativeScript Fetch to HttpClient Conversion and Gotchas

NativeScript Fetch to HttpClient Conversion and Gotchas

digitalix profile image Alex Ziskind Originally published at nativescripting.com Updated on ・2 min read

Converting fetch to HttpClient to make API calls is pretty straightforward. But sometimes it's not done correctly, especially when abusing the async pipe.

It may be beneficial to use HttpClient instead of the good old global fetch API that lives in a browser and NativeScript apps alike. When building Angular apps with NativeScript, using HttpClient has some added sugar like being able to use Http interceptors as well as getting an RxJS Observable as a result by default. But there are some things to watch out for when converting from using fetch to using HttpClient.

In this second part of the two-part video series, I first show you how to perform the conversion from the fetch API to using HttpClient in a NativeScript with Angular app. Then I show you some troubles you can face that may not be so obvious on the surface. And, of course, I'll show you how to eliminate those troubles.

This video builds upon what we've already done in part one: Easy Dev Backend for NativeScript apps.

You can find a lot more NativeScript Tutorials on my YouTube channel: https://www.youtube.com/channel/UCajiMK_CY9icRhLepS8_3ug

You'll find more content about NativeScript in our courses area on NativeScripting.com. The new Hands-on UI course is a pretty popular starting point for those starting out learning NativeScript and how to work with UI.

Let me know if you enjoyed this short tutorial on Twitter: @digitalix or comment here. And send me your NativeScript related questions that I can answer in video form. If I select your question to make a video answer, I'll send you swag. Use the hashtag #iscriptnative.

Discussion

pic
Editor guide