Interacting with a REST API | HTTP Methods, Status Codes... | Consuming a REST API in Flutter #3

preview_player
Показать описание
In this video I show you how to make a GET request to a REST API in Dart Flutter utilizing the http package. If you're not familiar with REST APIs don't worry, I explain what HTTP Methods, Status Codes and Headers are. I also demonstrate how to consume a REST API in a Flutter application and I demonstrate how to display the data that you retrieve. I also show you how to handle errors that a REST API may return

►CHECK OUT THE OTHER PARTS TO THIS FREE COURSE◄

►SUBSCRIBE TO THE CHANNEL◄

►FOR ANY QUESTIONS CONTACT ME AT◄

►SOURCE CODE◄

►THE API USED IN THIS VIDEO◄
Рекомендации по теме
Комментарии
Автор

Here to see how to consume a GET request in flutter? Click this: 14:10 to skip explanation on JSON and HTTP.

Great work as always, Boris!

mehdi-andrebappert
Автор

For the people new to the series, here are some errors you might face in this video and their solutions.

In class NotesService the API address has changed and it will now be

If you are using http: ^0.13.3
package which is the latest package, then you will get this error:
Error - The argument type 'String' can't be assigned to the parameter type 'Uri'
Fix - return http.get(Uri.parse(API + '/notes'), headers: headers).then((data)
You need to add Uri.parse before the API variable.

Hope this helps debug your code faster ✌️

marufhassan
Автор

This is an absolute gem content loved you put so much hardwork in these.
Keep them coming please.🚀

harshchaudhary
Автор

21:56, No I am stupid, made me laugh. If you call yourself a stupid, then what are we? HAAHHA, You're a rockstar brother. Great tutorials !! Live Long.

intellectsoft
Автор

That's some sort of professional coding standard.. amazing tutorial i also like to use service layer to seperate business logic from main screen just like in angular 😁 .. and yeah whole video was so informative with api status code and all but anyway amazing video. I appreciate your hard work .. thanks brother..

TheEntium
Автор

Respected Sir,

You are doing really great content and really helpful for flutter you very much

sumeetsolse
Автор

Thank you so much for this video. Actually I was looking for this real time api's no one has not did making this video. Thanks a lot 😀😀😀😀looking forward with more videos using rest api with authentication tokens.

RamKumar-zfcl
Автор

please can you update the link to the swagger documentation
this is what I got: "Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds."

inilonge
Автор

Thanks for an excellent video. You do it so clearly and easily, and I have learned a lot. Thanks for all your hard work.

pat.chandler
Автор

Hey, I loved your content and am going for the hands-on approach so I tried using the API link that you mentioned. Also picked the ones mentioned in the comments as updated but unfortunately they are not working. Can you please fix this? Thanks in advance and keep up the good work bro!

sakshamgarg
Автор

Thanks man.
saved my day.
keep sharing Knowledge

lightsunmirror
Автор

Where is the API link i am stuck,
Api Link not FOund

mudasirkhan
Автор

fu**, i wanted to do this in web, but its only worked on emulator, ty for guide, i got a test app from company, exactly what you do in you videos, ty <3

kantulaev
Автор

Thank you for the tutorials, they have been very helpful. Quick one, where is the source code you used to create the endpoints on this video? I am new to REST API. Maybe a much simpler question what is swagger UI connecting to in order to execute the end points.

pfunzonthambeleni
Автор

Nice content> I am justing trying out using restAPI's with flutter but the API link seem to be offline. Please can you do sth

uni-tek
Автор

Please share the link you used on SwaggerUI, also can you suggest any tutorials where you created this api

srineeshsalur
Автор

I am very impressed with your great flutter tutorials! Unfortunately I get the http error code 502 back!

hanspeterhuber
Автор

Hello, I'm trying to check the documentation for the api, but it tells me "502 error", thank you very much, you really helping me.

jasonherrera
Автор

@Programming Addict : I have a doubt in ProductService class. How can I pass the shared preference data( which holds my user data) in to the Class ProductService . I found no way for passing my shared preference data into the super class. I tried to create initState inside ProductService class but it throws error. Can you give me a hint about this?

nirmalasudhir
Автор

Great content!
I do have a question..

Not sure if this is because of recent flutter updates. But Ive ran into this error before when passing a URL to http.get.
I get The argument type 'String' can't be assigned to the parameter type 'Uri'. For the life of me I cant figure out what it wants and why a string isn't enough.


class NotesService {
static const headers = {'apiKey': mykey takenout'};

getNotesList() {
return http.get(API + '/notes', headers: headers).then((data) {
if (data.statusCode == 200) {
final jsonData = json.decode(data.body);
final notes = <NoteForListing>[];
for (var item in jsonData) {
final note = NoteForListing(
noteID: item['noteID'],
noteTitle: item['noteTitle'],
createDateTime: DateTime.parse(item['createDateTime']),
latestEditDateTime: item['latestEditDateTime'] != null
?
: null,
);
notes.add(note);
}
return notes);
}
return true, errorMessage: 'An error occured');
})
.catchError((_) => true, errorMessage: 'An error occured'));
}
}

harrisoncorupe