Fetching Data with Get requets | Angular HTTP | Angular 13+
In this lecture we will learn how to fetch data from the server and display that data in the web application. To fetch data from the server we use GET request and to send a GET request to the server, we can make use of get() method of HttpClient.
In this lecture you will learn:
1. How to send get request to the server?
2. How to transform the response returned by the server?
3. How to display the response data in the webpage.
DOWNLOAD STARTUP PROJECT HERE: drive.google.com/file/d/1cYuD...
Пікірлер: 21
I've explored numerous Angular tutorials, but this one stands out as truly exceptional. The clarity of instruction and depth of content make it a superior learning resource, providing valuable insights and enhancing my understanding of Angular development.
This was great. I built my copy by using a List component and an Add component, and having Add do an Emit, List then executes a Refresh by getting called through ViewChild. No need for refresh buttons. Best wishes!
just a neat and clean explanation.. i found it wonderful.. thank you sir for the wonderful explanation
Question: In 'onProductCreate()' , i used 'onProductFetch()' method also in method definition, so that when i create a object, it will automatically gets displayed. when compiled, its not working. But when i used a setTimeout() method for 1000ms outside 'onProductFetch()'. its working perfectly. Why it's happening?
You are the best)
Hello sir, Is there any other way to view data in html instead of transforming/observable operators ? can we do that using *ngFor directive or forEach method ?
thank you sir
thank you for the great educational material and amazing presentation. a quick question: is there any reason for using http instead of fetch api offered by the browser?
@procademy
Жыл бұрын
We can surely use fetch() api from angular. But its better to use angular's built-in http to handle http request and responses. This stackoverflow query might clear your doubt: stackoverflow.com/questions/53660262/angular-http-vs-fetch-api
my API return a simple text, in angular, how can i take the result that comes in json and convert to text?
I still receive the error after I change strict to false. Great videos though keep it up!
@sachinvarghese2223
Жыл бұрын
Instead of for..in method ; use this on your own risk (especially incase of nested object 😬) : for (const [key, value] of Object.entries(res)) { products.push({ ...value, id: key }); }; // no need to use hasOwnProperty() method, if we use entries() method
good morning sir i have tried to add product but i get an error while add new product
Great explanation, but what happened with json data that contains more than one object, i mean like a nested table? thanks for share your knowledge. btw i'm knew with angular, and sorry for my english xd
@procademy
Жыл бұрын
Thank you 😊. To access nested data, you can simply use dot notation. For example, let's say we have following json object: { Name:. "John", Address: { City: "London", Country: "UK" } } Now, if you want to access city field of address, which is a nested JSON object, you can access it like doc.address.city where doc is your variable storing the JSON object.
sir , why you didnt use services for http methods which could be more suitable to understand
hello sir, if(res.hasOwnProperty(key)){ products.push({...res[key], id:key}); } is the problem, your download source there is no content, it is empty project setup only, please update the full code and give us
@sachinvarghese2223
Жыл бұрын
i think use Object.entries() method instead of for..in loop. I am not sure though if it leads to some error😬 ; especially in case of nested object (sorry , i am noob in coding)
Sir, Thx for your great course. I got cors error by the get request. I tried to set the header without success and the Firebase Realtime Database parameter setting failed too. Please help.
@deresszakal
Жыл бұрын
Sorry, I entered the url incorrectly. What confused me was that I got a CORS error. It works now. THX.
res.hasOwnProperty(key) is useless when it put inside for(const key in res) {}. It will always be true.