Back to Browse

Fetching Data from API | Part - 3 | HTTP get Request in Flutter | Hindi

17.4K views
Oct 23, 2022
19:03

To fetch data from an API in a Flutter app, you can use the http package, which provides a simple and efficient way to make HTTP requests and receive HTTP responses. Here is an example of how you might use the http package to fetch data from an API in a Flutter app: import 'package:http/http.dart' as http; // Make a GET request to the API final response = await http.get('https://example.com/api/data'); // Check the status code of the response if (response.statusCode == 200) { // If the request was successful, parse the JSON data final data = json.decode(response.body); // Use the data as needed } else { // If the request was unsuccessful, throw an error throw Exception('Failed to fetch data'); } In this example, the http.get function is used to make a GET request to the API, and the response object is used to hold the response from the server. The statusCode property of the response object is used to check whether the request was successful or not, and the body property is used to hold the data returned by the server. You can also use the http package to make other types of HTTP requests, such as POST, PUT, and DELETE, by using the http.post, http.put, and http.delete functions, respectively. My YouTube Gear: Boya BYM1(Mic): https://amzn.to/3bvm69j Redmi Note 7 Pro(Mic & Camera): https://amzn.to/3uRkVsb MSI Motherboard: https://amzn.to/3fiQHYO Intel i3 Processor: https://amzn.to/3w8TWbQ Mouse: https://amzn.to/3yb8PMP Keyboard: https://amzn.to/3bvmtkd Wifi Adaptor: https://amzn.to/3fiQYuO SSD: https://amzn.to/3w2w2Pa Speakers: https://amzn.to/3w6pKhv Instagram: https://www.instagram.com/ahirlog/ Facebook: https://www.facebook.com/ahirlog Twitter: https://twitter.com/ahirlog YouTube: https://www.youtube.com/ahirlog #ahirlog #flutter #dart Last Summer by Ikson: http://www.soundcloud.com/ikson​ Music promoted by Audio Library https://youtu.be/n2oTA5JSk80

Download

1 formats

Video Formats

360pmp433.1 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Fetching Data from API | Part - 3 | HTTP get Request in Flutter | Hindi | NatokHD