HomeОбразованиеRelated VideosMore From: Codevolution

Angular 7 Tutorial - 21 - Fetch Data Using HTTP

1678 ratings | 211980 views
Support - https://www.paypal.me/Codevolution Facebook - https://www.facebook.com/codevolutionweb Github - https://github.com/gopinav Angular | Angular Tutorial for Beginners | Fetch Data Using HTTP
Html code for embedding videos on your blog
Text Comments (155)
Codevolution (1 month ago)
*There is a change in rxjs version 6. Please watch this video to fix that.* https://www.youtube.com/watch?v=ScaKGrW5s0I
ifthikkarudheen t (4 months ago)
iam using angular7 when i subscribed to observable it is showing error " cant find name 'subscribe' "
Manish Juniwal (9 months ago)
Very nice.....thnx.....do upload more videos
Fieel Flying (9 months ago)
Awesome, thank you!
Rafael Lauxen (1 day ago)
Nice tutorial!
Vanz Investor (3 days ago)
Angular 7 use *import { Observable } from 'rxjs';* instead of import { Observable } from 'rxjs/Observable'
orz (10 days ago)
please why using the interface ? it doesn't matter what i write inside and i return the type in the get function and it's still works. why using types and why using the interface ... ?
404 (11 days ago)
Help!!! How can i bypass CORS policy in Angular 7?
kushal patel (9 days ago)
On your api server you need to specify a cors policy
VOLT DOG (14 days ago)
I had an issue locating my employees.json file, I had an assets folder within src/app/assets and one within src/assets, I deleted the one in src/app/assets and put the json file in the src/assets folder directly and this got my app to work! Hope this helps anyone!
Hrishikesh Mithbavkar (1 month ago)
wonderfu!
Zawodowieec (1 month ago)
This video is outdated. Sad to say but it's your first video which i disliked :(
Zawodowieec (1 month ago)
+Codevolution Yes, know it ;) All the others are thumbed up.
Codevolution (1 month ago)
I know, sorry about that. I have pinned the updated video url :)
Rakesh R (1 month ago)
When I try to use data getting the error Cannot find name 'data'.ts(2304)
Vivek Shrivastava (2 months ago)
Thanks for nice explanantion.. really helpfull video..
Jitendra Kumar Sharma (2 months ago)
this project is not working in angular 7
manisha yadav (2 months ago)
Where is html
Abhijit Worlikar (2 months ago)
very Good explanation..!!
Shailesh Singh (3 months ago)
hi i am trying to do same but with server my both url getting appended because of relative url eg localhost:4200/app/localhost:8080/serviceapp/api/getmethod how do i solve it i read few answer they are telling me to user post instead of get
pGpants (3 months ago)
Guys use fetch js❤️
Rajesh Naika (3 months ago)
Sir can you provide angular material course
Sofian Meriane (3 months ago)
awesome tutorial thanks much Vishwas
Sofian Meriane (3 months ago)
awesome thanks very well Vishwas
Oleg Vasilyev (3 months ago)
In general, quite a useful video. But in fact, the result is a memory leak in employee-list.compopent. You can solve this problem by assigning a subscription to a variable. eg this._subcription = this._employeeService.getEmp. And execute this._subcription.unsubscribe() in ngOnDestroy. Or it is better to not subscribe at all. Instead, display data through the async pipe in the template. This is the best practice - because Angular will take care of unsubscribe .
Thank God till this tutorial I didn't got stuck anywhere, got running everything. Thanks
Akshay Gupta (4 months ago)
Good Job man!!!very good way to explain the concepts in a easy way..Thanks
Danton Barnes (4 months ago)
You should do a tutorial on how to create a web api using express and mysql.
jonatasge (4 months ago)
I do not speak and I do not understand English, but I was able to understand and learn a little Angular with your video. Thank you very much.
Yash Singh (4 months ago)
How it's automatically cast observable into employee array,don't we need to use map operator
Daniel White (4 months ago)
Wow, I spent two days following these steps. This does not work retrieving data from a file. A waste of time.
TightyWhities94 (4 months ago)
Newbie here. Excuse me if it sounds dumb but why did we create an Employee interface instead of an Employee class? Doesn't casting work with classes?
TightyWhities94 (4 months ago)
+Codevolution thx ^^
Codevolution (4 months ago)
Hello, I hope this article will help you - https://toddmotto.com/classes-vs-interfaces-in-typescript . But in short, yes you could use classes. And you don't have to excuse yourself for asking questions. It's how you learn :)
Best Bhajan (5 months ago)
Excellent. Nice Explained!
ger scorpion (5 months ago)
how can i connect with an existing phpmyadmin sql database?
Sanjeev Dhillon (5 months ago)
If i using a real api, how would i my interface look, for example if the api has { "page": 1, "results": [ { "adult": false, "backdrop_path": "/VuukZLgaCrho2Ar8Scl9HtV3yD.jpg", "genre_ids": [ 878 ], "id": 335983, "original_language": "en", "original_title": "Venom", "overview": "movie summae", "poster_path": "/2uNW4WbgBXL25BAbXGLnLqX71Sw.jpg", "release_date": "2018-10-03" } would i make my interface like export interface ITrendingMovies { results: [ { id: number, title: string } ]; } any help please? I can get the api to log in console if i do subscription in the service then just call function in my home component so i know the api does work and does get data back but obvs i dont want to do the api call in the component.
HUSNA KHANAM (5 months ago)
I have followed same steps of the tutorial with angular 7 being with angular/cli version 7.1.0 and rxjs version to be 6.3.3 but getting an error of being that"cannot find name 'subscribe"[email protected]
Codevolution (5 months ago)
There is updated version of HTTP and services please refer to https://www.youtube.com/watch?v=ScaKGrW5s0I
Shripad Avhad (5 months ago)
How to fetch nested JSON data?
sir how to get data using url
Amit Moral (6 months ago)
How to use array object of Json Data... (Many array in on Json File)
Dimitar Tsvetkov (6 months ago)
Great explanation, thank you, sir ;)
Wanderson Santos Costa (6 months ago)
Fix for those who are having issues with Observable on Angular 6+ just run the command "npm install rxjs-compat" then you should be good to go
Fethi Yacine (6 months ago)
Good tutorial
Ashish Guitarist (7 months ago)
What will happen if we have let say home and employee components with routing enabled, then in this case also, can we read json file as done in the video?
Jason Lado (7 months ago)
please help me this error in my employee service "[ts] Property 'get' does not exist on type 'HttpClient'. i already have imported it in my module
bobby cvSixFour (7 months ago)
best described Observable and Subscription ever (starting at 5:20)
Bunthai Deng (7 months ago)
What does it mean by "data arrives asynchronously"?
Sarthak Tuteja (7 months ago)
why use observable and not promise? what is the difference between them?
bhenjyl maypa (7 months ago)
i have this error ERROR in node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'. src/app/employee.service.ts(4,10): error TS2305: Module '"C:/Users/OJT/Documents/angular/codevolution/node_modules/rxjs/Observable"' has no exported member 'Observable'. src/app/test/employee-details/employee-details.component.ts(16,5): error TS2322: Type 'Observable<IEmployee[]>' is not assignable to type 'any[]'. Property 'includes' is missing in type 'Observable<IEmployee[]>'.
bhenjyl maypa (7 months ago)
is it okay to remove the import observable from ..rxjs?
Manthan Pawar (7 months ago)
i request to you to create video how to use mysql in angular 6 please please fastly or the video is there so please send me a link.. thank you
Sanches Panches (7 months ago)
it looks like we should import Observable from 'rxjs', not from 'rxjs/Observable'
Merlin Grim (8 months ago)
FYI - if your import of Observable is failing because you are using version 6 then try this: import { Observable } from 'rxjs';
In Angular 6, this is done automatically, great
Wanderson Santos Costa (6 months ago)
For those who are using Angular 6+ just run the command "npm install rxjs-compat" then you should be fine.
IBHimself (7 months ago)
it is going to be automatically imported on VS code, it was puzzling at first but yeah
sateesh kumar (8 months ago)
is it possible to to use one Angular component in our own html file and At the same time is it possible to access all the properties of that Angular properties.please any one tell me.(the html file is not included in our Angular Application,html file completely will be in outside.). is it possible???
Alex Dovbash (8 months ago)
Thank you very much its the best course for beginners for sure thank you!!
sanjana tyagi (8 months ago)
I have 2 lakhs record in a table.. i created API taking the data from table and I need to show it on UI but the problem is that unil we don't subscribe to API url the data is not getting displayed on UI. Is there any solution of this? I need to display data on UI without waiting for whole data to get subscribed
Sarthak Tuteja (7 months ago)
I am noob into this, but I read somewhere that promises doesn't wait for .then() so I think u should use it. But again saying I am very noob so idk if that's a good idea or if it answers your question..
Ed Salazar (8 months ago)
Excellent video series on Angular. I really appreciate the work you have done. Thank you!
ahsan baloch (8 months ago)
please make a video on post request
Walid PAKACHI (8 months ago)
Man, you just saved my day .. I have been searching for you for a long time !! THNX
ANANTHA BALAJI .D (8 months ago)
subscribe(data => this.employees=data); What is the actual use of the '=>' operator. I couldn't understand the syntax
Raj thilak (6 months ago)
it's an arrow function in ES6. this syntax is similar to normal function in Javascript. function(data){ this.employees = data; } Here data is an formal parameter or formal argument for the function.
ChroniZz (8 months ago)
you should go back and watch the es6 tutorials.
Udara Attanayake (9 months ago)
clear
Annu ttl (9 months ago)
whether observable to be used for fetching a single user details?
Abhishek Konda (9 months ago)
Superr Videos.....
Absar Khan (10 months ago)
you are superb sir, and your all videos are amazing.
Mayur Hadawale (10 months ago)
How to check if data variable in subscribe method is null or not? If null then redirect else assign data to employees
sachin badnikai (10 months ago)
sir please make crud operation video
moduthoms (10 months ago)
Very good explanation. Not even Angular official site tutorial explains like this.
NITESH SINGH (10 months ago)
Error : TypeError: this._employeeService.getEmployees is not a function...help
Repon Hossain (10 months ago)
How can I use dynamic template_url at decorator on Angular 6? example: view.html, edit.html, so on...
Zhao Rui (10 months ago)
Should interface values be separate by semicolon ; or comma , ?
MD.JULHAS HOSSAIN MOHON (10 months ago)
So Cool Man !!!... Just Described On to the point .. Great Work. !!!
Ashish Singh (10 months ago)
The Big one Bro...Completely understandable
Linel Sedillo (10 months ago)
Hi, thank you for this tutorial. thou my subscribe method has an error of this "subscribe is not defined " how can I fix this?
Codevolution (10 months ago)
Make sure you have all your imports. Rxjs imports have been updated. See the link in the pinned comment :)
Conor D (10 months ago)
hi, thanks for ur videos but i got a problem, in ng 6 with cli, i generate a service and the cli is automatically injected into the root, maybe it's not bad i don't know.
Conor D (10 months ago)
Thanks, I'll keep watching :)
Codevolution (10 months ago)
That's a good thing :) Updated video is pinned as comment. Make sure to go through that after watching all the videos about services :)
fitTech buddy (10 months ago)
And why interface is used. I mean can't we do that same work by some other method. ??
Codevolution (10 months ago)
Sure you can do the same without using interface. It just ensures less errors in large scale applications. For small ones you can totally leave it out :)
Syed Hasan (10 months ago)
Thanks a lot! Your series is really useful.
HoodedWarrior (10 months ago)
the rxjs Import isn't up to date with rxjs 6.. to any one else who is struggling. Also I figured this out after I ran the ng lint and resolved all the other suggestions... npm i --save rxjs-compat .. found the solution on stack overflow. you can import after: import { Observable } from 'rxjs/Observable'; Also if you are a noob like me, don't use arrow functions or fat arrow, while it is shorter, for me at least it makes me overlook the fact that we actually pass an arg there, use regular function syntax.
Damien MATHIEU (2 months ago)
Thank you for this adding "npm i --save rxjs-combat" without it l will always be in the "failed to compile"
Sanmesh Patwa (7 months ago)
if you find the solution ,let me know too!!
Sai Sushmitha (7 months ago)
Hi, can you explain how to resolve this error "Cannot find name 'subscribe"!!?
alke2007 (9 months ago)
Thank you !!! That solved the problem
Chanan Markowitz (10 months ago)
Hi Everyone. can someone please explain me why he is using An Interface (export Interface IEmployee) instead of a class (export class Employee)? thanks !
Lynn Bernard (10 months ago)
You can use either an Interface or a class. It was his choice to use an interface in this video, but it's not necessary.
Vignesh Viswanathan (10 months ago)
Well explained!
Hen Levi (10 months ago)
thanks,great video
Alex Vollo (10 months ago)
This is a very good explanation!!
ram yadav (10 months ago)
Thanks for making a nice video.
Nishtha Jain (11 months ago)
when i subscribed to observable it is showing error " cant find name 'subscribe' "
ifthikkarudheen t (4 months ago)
did you get the solution ? iam also facing the same problem
Willard Shikami (11 months ago)
This is Gold, thank you!
Hemanth SP (11 months ago)
Finally I understand thx boss
ndnNinja 15 (11 months ago)
This is the best tutorial on the subject. Thank you sir!
Me and You (11 months ago)
with web service not working this solution. sorry
vidyut bharath (11 months ago)
Thank you so much...good video...
Atul Srivastava (11 months ago)
Very well explain.. You clarified my doubts. Thank you so much.
Miguel Britos (11 months ago)
thanks man!! I was finally able to make it work, your explanation is great!
KangoV (11 months ago)
How would you code this to return an Observable<IEmployee> and not the whole array? For example, in Java you you would do this with a Single<IEmployee[]>, not an Observable.
Anand Jagtap (11 months ago)
How to use react js with angular 6
Jesús Bossa (11 months ago)
what can i do if the api send me a nested json, my app send me an error like 'object dont have the property'
Kim 92 (11 months ago)
Hi, Sir, thanx for making tutorials on Angular 6. i learnt a lot of concepts from your tutuorials such as Di, Observables...etc i think your concepts are crystal clear! and also your teaching methodology is so much awesome! i like the way as you teach. Sir i'v a request, kindly make a tutorial on LOGIN AND REGISTRATION SYSTEM in MEAN STACK 6 or at least 5 using mongoose i am waiting your response imran khan from Lahore, Pakistan
Just a quick question. After we subscribe, since is Async, wouldn't be the left off data or replaced data be a memory leak? how can we prevent that?
Allright, thanks a lot man !
Codevolution (1 year ago)
The component class should implement OnDestroy, and you need a reference for the subscribed observable and then unsubscribe in ngOnDestroy(). A quick google on "unsubscribe observable in angular" will give you just what you need :)
I can put ngOnDestroy() on HTML string? or should i use unsubscribe on the component.ts?
Codevolution (1 year ago)
Yes, we will have to unsubscribe in ngOnDestroy()
Kolos (1 year ago)
Thanks man, this helped me. And even more, this made mE to subscribe(); to your channel! *Bdum tsss* :)
Anthony Mark Peirson (1 year ago)
Very very good. Thanks for all your hard work :-)
Drakshop (1 year ago)
at 4.10 instead of commas maybe we should seperate properties in an interface with a semi colon;
gokulakrishnan ks (1 year ago)
Second time I am getting empty data when i am trying to fetch and process the data.
Cyrus Besabella (1 year ago)
Thank you sir!
Subin Y. (1 year ago)
thanks..
Ayushman Srivastava (1 year ago)
when i create interface tslint says we have to use semicolons , how is your code working ??
farham heidari (1 year ago)
I didn't create the interface for Get method, I didn't use Observable, it still works. ... when it is required to use them .?
Saravana Prakash (5 months ago)
Point number 2. Receive the observable and cast it into employee array. Is not clear in this video. Try to create models to store the data from API's
Darshit Ankoliya (1 year ago)
Thank you so much , it's helping me lots
Nathaniel Berens (1 year ago)
I have followed this and other tutorials on how to get json data via get, and I show an error in console of [object Object]. I have copied the component.ts file and services.ts file exactly. I verified my json with jsonlint. the [object Object] error is driving me crazy! Any ideas on what may be happening?
Raj thilak (6 months ago)
+Codevolution what exactly the JSON.stringify will do??
Codevolution (1 year ago)
Hi Nathan. What do you mean by [object Object] error? That is not an error, use JSON.stringify to see the object.
francis kiragu (1 year ago)
very good videos....thumbs up
David Donadze (1 year ago)
no one has explained this subject the way u did it. love your videos.
IT- Creativv (1 year ago)
You're awesome!

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.