Fetching an API (Simple GET Request) with Loading Spinner in React Native App

Fetching an API (Simple GET Request) with Loading Spinner in React Native App

MissCoding

2 года назад

28,996 Просмотров

Hi everyone!

Today I am going to show you how to make a GET request to an API from a React Native app. I will also show you how to use useEffect to ensure the API is only called on the React component mounting. While the API call is loading we will display an ActivityIndicator on screen to indicate loading and improve user experience.

My code is available on GitHub:
https://github.com/chelseafarley/ReactNativeFetchApi

You’ve clearly come here to learn and a free audible trial allows you to increase your learning potential in situations where you may be hands free like at the gym or on your commute. It allows you to spend more time on theory when you aren’t able to watch a screen, so that you can maximise your screen time to pick up technical skills. Try it for free today:
https://amzn.to/3ECMsom

// ABOUT ME
My name is Chelsea and I started studying software engineering in 2010. I have been working commercially full time since 2014 and have been in various positions from graduate developer to tech lead to solution architect.
I'm a full stack developer with a lot of experience in C# and Javascript but my passion is for mobile development; specifically native iOS development and cross platform using React Native.

I always have many things on the go and am always trying out a new side hustle and failing at it; perhaps you can learn from my mistakes!

Please like and subscribe if you enjoyed this video and want to see more like it!
Have any suggestions on topics you would like to learn more about? Please suggest them in the comments... I would love to help you out while doing a bit of learning myself!

// PRODUCTS USED
I use the following products in the creation of my videos:

Boya MM1 Microphone - https://amzn.to/3m6kif7
A reasonable quality and reasonably sturdy but cost effective microphone that can be used by both DSLR cameras, mobile phones and laptops

Canon 18-55mm Lens - https://amzn.to/3IwscFR
A kit lens but a decent quality lens for beginners getting used to a DSLR

Canon EOS Rebel T7 with 18-55mm Lens - https://amzn.to/3XZauAL
This is the kit I started with it includes the lens linked above and is a great starter camera.

I love Apple devices... These are the ones I use for my channel content creation:

Apple iPhone 13 - https://amzn.to/3KAUba4
A good all round phone, good for Apple development and recording videos with enough high quality features but at a cheaper price point than the pro versions.

Apple MacBook Pro - https://amzn.to/3KxrE5q
A nice portable computer for working from anywhere and perfect for iOS development

Apple iPad Air - https://amzn.to/3xU2k21
Really easy to use for graphic design if required for logos as part of my app development or editing the videos on the go.

Apple Pencil (2nd Generation) - https://amzn.to/3EBSwNS
For logo and icon design in Affinity Designer app for iPad

Logitech Folio Keyboard Touch - https://amzn.to/3XUYBM1
Adds keyboard and touchpad to iPad Air, making it easier to use for writing code/eBooks etc. on the go!

DISCLAIMER: Links included in this description might be affiliate links. If you purchase a product or service with the links that I provide I may receive a small commission. There is no additional charge to you! Thank you for supporting my channel so I can continue to provide you with free content each week!

//CONTACT:
Please contact me at: [email protected]

//CRAVING MORE:
You can find links to all my different sites and social media over on Linktree: https://linktr.ee/misscoding

Тэги:

#react_native #react_native_tutorial #react_native_tutorial_for_beginners #react_native_http_request #call_api_react_native #activity_indicator_react_native #simple_get_request_react_native #react_native_get_request
Ссылки и html тэги не поддерживаются


Комментарии:

Vlastimil Slechta
Vlastimil Slechta - 23.03.2023 13:27

Thank u ! 😊

Ответить
Lyle McCalmont
Lyle McCalmont - 08.02.2023 11:42

Thank you for this @MissCoding - excellent tutorial for simple API connectivity. I get the same error "undefined is not an object (evaluating 'response["bpi"]')

If I remove the line return <Text>Bitcoin (GBP): {response["bpi"]["GBP"].rate}</Text>; and readd it it works first time but then fails every time after.


Any idea what the issue is @MissCoding?

Ответить
Job Armure
Job Armure - 05.02.2023 16:48

Thx very much for the explanation, very easy to understand

Ответить
Dany Spb
Dany Spb - 12.01.2023 19:51

thank you so much it easy to understand

Ответить
Benjamin flor
Benjamin flor - 02.12.2022 01:22

so good teacher

Ответить
faiz masroor
faiz masroor - 16.10.2022 13:31

thanks and love from pakistani mobile app developer .

Ответить
K T
K T - 21.08.2022 01:57

Fantastic! Simply explained and very straightforward. Thanks!

Ответить
Kashif
Kashif - 23.06.2022 10:50

I'm getting an error saying "undefined is not an object (evaluating 'response["bpi"]')

Ответить
RK Shani Gaming
RK Shani Gaming - 17.06.2022 13:35

Lovely its really helpfull for me...❤❤

Ответить
Jordy Yeoman
Jordy Yeoman - 12.06.2022 15:28

Yo! Holla from Perth WA! Your accent sounds like you’re from NZ! 🤙
Awesome tutorial 👏 keep up the awesome work

Ответить