React Native

React Native Networking & API

fetch API, axios, async/await, error handling, API integration, AbortController

20 Interview-Fragen·
Mid-Level
1

What is the native JavaScript method for making HTTP requests in React Native?

Antwort

fetch is the native API built into JavaScript and React Native for making HTTP requests. It returns a Promise and allows handling GET, POST, PUT, DELETE requests without external dependencies. Unlike axios, fetch is available natively without installing any package.

2

What does the fetch() method return when an HTTP request fails with a 404 or 500 code?

Antwort

fetch() always resolves the Promise successfully as long as the network request completes, even for HTTP error codes like 404 or 500. You need to check response.ok or response.status manually to detect HTTP errors. fetch() only rejects the Promise for actual network errors like no connection.

3

What is the main advantage of axios over fetch for HTTP requests?

Antwort

axios automatically transforms JSON data into JavaScript objects and handles HTTP error codes by rejecting the Promise. With fetch, you need to call response.json() manually and check response.ok. axios also offers interceptors, simplified cancellation, and better default timeout handling.

4

What is the correct syntax for sending JSON data with fetch in POST?

5

How does async/await simplify HTTP request handling compared to chained Promises?

+17 Interview-Fragen

Meistere React Native für dein nächstes Interview

Zugang zu allen Fragen, Flashcards, technischen Tests, Code-Review-Übungen und Interview-Simulatoren.

Kostenlos starten