Display Json Array Angular 5 HttpClient

Display Json Array Angular 5 HttpClient

how to get value from a nested json array in angularjs template
how to fetch value from the nested json array in angular 6
how to create json array in angular 4
angular 6 rest api example
how to iterate json array in angular 7
angular 4 convert json to array
how to get data from json object in angular 6
angular 4 get data from api

I'm a beginner in Angular5 and I need your help...

I made an API in my backend (Java/Spring Boot) which I can access with http://localhost:8080/applications

With this API I want to retrieve a chunk of data (it's a JSON Array).

I try to retrieve data with httpClient on my Angular but I have this result in my frontend : [object Object]

This my app.component.ts


    import {Component, Injectable} from '@angular/core';
    import {HttpClient, HttpErrorResponse} from "@angular/common/http";
    import {Observable} from "rxjs/Observable";
    import 'rxjs/add/operator/map';

    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.scss']
    })

    export class AppComponent {
      url = 'http://localhost:8080/applications';
      res = [];

      constructor(private http: HttpClient) {
      }


      ngOnInit(): void {

        this.http.get(this.url).subscribe(data => {
            this.res = data;
            console.log(data);
        },
          (err: HttpErrorResponse) => {
            if (err.error instanceof Error) {
              console.log("Client-side error occured.");
            } else {
              console.log("Server-side error occured.");
            }
          });

      }

    }

My Application interface Application.ts


    interface Applications {

      id : number;
      type : string;
      port : string;
      baseUrl : string;
      architecture : string;
      protocol : string;
      serveur : string;

    }

How can I display my data ?

Thanks in advance


Close enough, try this: in your app.component.ts you can just use the constructor with dependency injection, no need of ngOnInit(). One more thing, I'm not sure about your API Route. You should have something like http://localhost:8080/[controller]/[action] http://localhost:8080/application/getall http://localhost:8080/api/application/getall --> this one is used for this example.

import { Component, Inject } from '@angular/core';
import { Http  from '@angular/http';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'] })

export class AppComponent {
private url: 'http://localhost:8080/api/application/getall'
public apps: Applications[];

constructor(http: Http) {
    http.get(url).subscribe(result => {
        this.apps = result.json() as Applications[];
    }, error => console.error(error));
}}

interface Applications {
   id: number;
   type: string;
   port: string;
   baseUrl: string;
   architecture: string;
   protocol: string;
   serveur: string; }

in your app.component.html let try with an unordered list

<ul *ngIf="apps">
   <li *ngFor="let app of apps">
      {{app.Id}}
   </li>
</ul>

Put <app-root></app-root> where you want in your html to make the call.

One more step, in your app.shared.module.ts you have to import your component import { AppComponent } from './components/app/app.component'; and add your component to @NgModule declarations[]

@NgModule({
  declarations: [
   //...
   AppComponent
  ]
  //...

I hope this works

Display Json Array Angular 5 HttpClient - json - html, Display Json Array Angular 5 HttpClient - json. access with http://localhost:​8080/applications With this API I want to retrieve a chunk of data (it's a JSON Array). Display Json Array Angular 5 HttpClient. Ask Question Asked 2 years, 1 month ago. Active 1 year, 7 months ago. Viewed 25k times 4. 3. I'm a beginner in Angular5 and I


Hi #yupii7 thanks a lot to answer me. I try your code but it doesn't work in Angular5. But, when I simply use :


    public apps: Applications[];

    this.http.get(this.url).subscribe(result => {
            this.apps = result as Applications[];
        }

It works perfectly :)

Now, I need to find a way to push these data on a table. If you have an idea I will be happy to hear it. :)

See here ! To add a comment on yours I need 50 reputation, so I leave my comment here to make you see it. You need to ask a new question. See angular material or make your own table

Angular 5 - Reading data from Nested JSON, Angular 5 - Reading data from Nested JSON. arrCase = data as object []; // FILL THE ARRAY WITH DATA. httpClient.get<Drug[]>(this. Fetching and Displaying filtered Json data from API(very very urgent) · Fetching and  Con esta API quiero recuperar un fragmento de datos (es una Matriz JSON). Trato de recuperar los datos con httpClient en mi Angulares, pero tengo este resultado en mi frontend : [object object] Esta mi de la aplicación.componente.ts


You can simply do that by using angular pipes if you just need to see data In view

<div>
{{res|json}}
</div>

How to fetch value from the nested json array in angular?, how to store the result of the JSON-RPC response to a variable? Redirect to previous page after login · Fetching and Displaying filtered Json data  Like Vue and React, Angular remains one of the most popular JavaScript frameworks or libraries. With Angular, it’s easier to write reusable, easy to maintain, readable code; hence, Angular is known for speeding up development time. In this article, you’ll learn how to get JSON data from an API and display in HTML, in quick time without


Angular 5: Making API calls with the HttpClient service, Angular 5: Making API calls with the HttpClient service Returns an array of all existing Food objects in JSON format. app contains only one simple component, which contains a few elements to display some simple data. As of Angular 5.0, the older Http service still works, but it's deprecated and has been removed in Angular 6.0. The code samples in this post are compatible with Angular 4.3 and 5.x (and 6.x with rxjs-compat). If your project is still using Angular 4.2 or lower, including Angular 2, see my previous posts on making API calls with the Http service.


Angular 9/10 Tutorial By Example: REST CRUD APIs & HTTP GET , cd ~/angular-httpclient-example $ npm install --save json-server GET /products​?_page=1&_limit=5 for getting the first five products of the first the products array using ngFor and used a Material card to display the name  How to store a json data in array only for particular id in angular 7 ; Angular- Get value from nested object in JSON ; angular 7 SEO change meta tags change in view html ; Angular Material Select : How to set selected group of options with mat-optgroup? logout all open tabs automatically when user logs out in one of them in angular 6


Read an External JSON file in Angular 4 and Convert Data to HTML , You can use the HttpClient service in Angular 4 to read and extract data from an external JSON file. Using the Related: How to Bind JSON array or data to an HTML table in AngularJS using ng-repeat Go the browser to check the output. Showing how to display the JSON data in Table using Angular 4 and 5 tech. Showing how to display the JSON data in Table using Angular 4 and 5 tech. Skip navigation Sign in. Search. Loading