DEV Community

Madhuja Mitra
Madhuja Mitra Subscriber

Posted on

Call API and get the value

Angular project:

we are make an API call to fetch value and display it on the UI for angular project.

I are using https://jsonplaceholder.typicode.com/ for getting Fake API calls for json value and using Angular v15.

Step 1. Angular project need to be created. Here my project name is API calls.

Step 2. Create a service , and we will be fetching the from the MOCK API.

Note a: We need to import httpClient for communicating API calls in Angular.

Image description

Note b: we need to import the HttpClientModule in app.module.ts to define the functionality of httpClientModule.

Image description

Step 3. Subscribe the value from the services to fetch the value the UI in new data component.

Image description

Step 4. Displaying the value in the UI

Image description

Step 5. Dont forget to connect the component to the app.component.html

you can see the value from the API call easily :)

Top comments (0)