quiz

Full-stack dev quiz question #55

Full-stack dev quiz question #55quiz

Asynchronous operations can be tricky in programming. Check fifty fith question of full-stack dev quiz to see what you know about sending HTTP GET requests in Angular TS and reading the response.

Look at the below TypeScript code:

import { Injectable } from '@angular/core';
import {Observable} from "rxjs";
import {HttpClient} from "@angular/common/http";

@Injectable({
providedIn: 'root'
})

export class BlogsService {
constructor(private http: HttpClient) { }

public getUsefulBlogs(): XYZ {
return this.http.get<Blog[]>("/blogs/useful");
}
}

export interface Blog {
name: string,
url: string
}

What object type (marked as XYZ) is returned by getUsefulBlogs() function? It basically returns the same as the get function of HttpClient. Choose the best answer.

  1. Blog 
  2. Blog[]
  3. HttpClient
  4. Event<Blog>
  5. Subscription<Blog[]>

For the correct answer scroll down

.

.

 

 

 

 

 

 

 

 

 

 

Do not miss valuable content. You will receive a monthly summary email. You can unsubscribe anytime.

 

 

 

 

 

 

 

 

 

 

 

 

 

.

.

.

The correct answer is: e. If you would like to read more, check Mocking REST API in AngularTS article.