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

.

.

 

 

 

 

 

 

 

 

 

 

Would you like to learn Liquibase? Enroll to my course on Udemy.

liquibase course promo

review

 

 

 

 

 

 

 

 

 

 

 

 

 

.

.

.

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

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.