33 | Angular में API को कॉल करना | Angular में API डाटा को फ़ेच करके दिखाना | Part-2 (हिंदी/उर्दू)

Posted by






33 | Calling API In Angular | Fetching And Displaying API Data In Angular | Part-2 (Hindi/Urdu)

33 | Calling API In Angular | Fetching And Displaying API Data In Angular | Part-2 (Hindi/Urdu)

इस आर्टिकल में हम आपको बताएंगे कि Angular में API कैसे कॉल करते हैं और उससे डाटा कैसे फेच करते हैं और फिर उस डाटा को अपने एप्लीकेशन में कैसे डिस्प्ले करते हैं। यह आर्टिकल पार्ट-2 है।

सबसे पहले हमें अपने Angular एप्लीकेशन में HTTP module को import करना होगा। इसके लिए हमें app.module.ts फ़ाइल में जाकर निम्नलिखित लाइन को जोड़ना होगा –

        
            import { HttpClientModule } from '@angular/common/http';
            imports: [
                HttpClientModule
            ]
        
    

इसके बाद हमें एक service बनाना होगा जो हमें API से डाटा फेच करने में मदद करेगा। उसके लिए हमें निम्नलिखित कमांड को चलाना होगा –

        
            ng g service api
        
    

इससे एक नया service फ़ाइल बनेगा जिसका नाम api.service.ts होगा। इस फ़ाइल में हमें API कॉल करने के लिए एक नया method बनाना होगा।

आखिरकार, हमें अपने component में यह service inject करना होगा और फिर उसके माध्यम से API से डाटा फेच करना होगा। इस डाटा को हम अपने HTML में डिस्प्ले कर सकते हैं।

इस तरह से हम अपने Angular एप्लीकेशन में API कॉल कर सकते हैं और उससे डाटा फेच कर सकते हैं। आप हमारे अगले आर्टिकल Part-3 का इंतजार करें जिसमें हम आपको डिस्प्ले डाटा को लेकर आगे की जानकारी देंगे।


0 0 votes
Article Rating
8 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Poornima Å
7 months ago

Constructor(private client:HttpClient) in this code error??

Anil Vishwakarma
7 months ago

In preview video you register service in provider but this this not?

TechLead-DOTNET
7 months ago

Very nice ! Requesting to prepare a video for deploying angular application on the server . which files will be moved what not moved set start page etc . Thanks a lot

Gaurav singh Rajput
7 months ago

sir please make video on angular ecommerse wesite project

Gaurav singh Rajput
7 months ago

ye thoda difficul hai

Neeraj Kumar
7 months ago

Angular key sath database sqlserver please sir

RAHUL SONI
7 months ago

Love from india thanks sir

Muhammad Naveed
7 months ago

Thanks sir..