Type 'Subscription' is not assignable to type 'Observable<SearchResult[]>' Angular 5 using HttpClient instead of Http

learn to type
type racer
learn to type for kids
nitro type
typing.com games
type thesaurus
free typing lessons
typing test

I'm trying to use the new HttpClient class instead of the old Http.

I want to map over the data I get from the subscribe method, but get the below error. Any suggestions on why I get this?


export class YoutubeSearchService {
    private http: HttpClient,
    @Inject(YOUTUBE_API_KEY) private apiKey: string,
    @Inject(YOUTUBE_API_URL) private apiUrl: string,
  ) { }

  search(query: string): Observable<SearchResult[]> {
    const params: string = [
    const queryUrl = `${this.apiUrl}?${params}`;
    return this.http.get(queryUrl).subscribe(data => {
      data.map(item => {
        return new SearchResult({
          id: item.id.videoId,
          title: item.snippet.title,
          description: item.snippet.description,
          thumbnailUrl: item.snippet.thumbnails.high.url,


ERROR in src/app/services/youtube-search.service.ts(26,5): error TS2322: Type 'Subscription' is not assignable to type 'Observable<SearchResult[]>'.
  Property '_isScalar' is missing in type 'Subscription'.
src/app/services/youtube-search.service.ts(27,12): error TS2339: Property 'map' doesnot exist on type 'Object'.

Your search method is returning a subscription but the signature claims it should return an Observable<SearchResult[]>

To fix this either change the signature of your method or change the subscribe to map

TypingClub: Learn Touch Typing Free, The award-winning online typing competition, TypeRacer, is the best free typing game in the world. Race against live opponents typing quotes from books,  type, kind, sort, nature, description, character mean a number of individuals thought of as a group because of a common quality or qualities. type may suggest strong and clearly marked similarity throughout the items included so that each is typical of the group. one of three basic body types kind may suggest natural grouping.

To return the Observable, use:

return this.http.get(queryUrl);

and do the subscription on the calling end. If you need to map your return object from the Http call to a different object. Then one solution would be to define a subject and inside your subscription, you perform a next operation on this subject.

As for the second error, you are getting for using map function. You can use return this.http.get(queryUrl); to make the compiler view it as a an array instead of a single object. I am not sure that this what you wanted to achieve or not.

Learn to Type, “and” in “red and white and blue” has two separate tokens. Type definition, a number of things or persons sharing a particular characteristic, or set of characteristics, that causes them to be regarded as a group, more or less precisely defined or designated; class; category: a criminal of the most vicious type.

easily , you don't use for return value.


Typing practice, Type definition, a number of things or persons sharing a particular characteristic, or set of characteristics, that causes them to be regarded as a group, more or  Learn the Foundations of Technology, FREE! Build essential skills with our comprehensive curriculum including keyboarding, digital literacy, and coding!

TypeRacer, ZType is sponsored by Typesy. If you would like to learn how to type faster, we highly recommend Typesy. It's by far the most awesome Typing program out there  Graduate from hunt-and-peck to touch typing mastery with our complete course of free touch typing lessons. Practice is the key to developing excellent typing skills. Make it fun by typing great quotes from great books! Evaluate your skills and measure your progress by taking a typing test.

Type, type meaning: 1. a particular group of people or things that share similar characteristics and form a smaller…. Learn more. Welcome to the #1 typing speed test with over 4 million tests completed every month! Start Typing Test. Now typing gets fun! Play our numerous fun typing games to become a true keyboard master. TypeTastic for Schools. Discover 700+ typing activities for all grade levels – and unleash the joy of typing in your school.

What is a good typing speed?, NounEdit. type (plural types). A grouping based on shared characteristics; a class​. quotations ▽. To be clear, TypeRacer is not an easy typing game, but it will actually make you a better typist than those easy typing games for kids. It makes you type the same sort of text you would see at typing jobs. Don't know how to type yet? Then learn to type! Just grab a free typing tutor or read a free typing tutorial.

  • I can't do map with httpClient. Or? Read blog.angular.io/… under HttpClient
  • You have to remove the map to json because the new HttpClient created a json object for you. So you can perfectly use a map if you want to change the returned object, or just remove it.
  • I get Property 'map' does not exist on type 'Observable<Object>'.
  • import 'rxjs/add/operator/map'
  • Hi @Venomy, Fixed it: jsfiddle.net/2w8xsqdo/2 now this error: file: 'file:///Users/isaklafleur/Google%20Drive/Isak/Coding/angular-youtube-search/src/app/services/youtube-search.service.ts' severity: 'Error' message: 'Type 'Observable<SearchResult>' is not assignable to type 'Observable<SearchResult[]>'. Type 'SearchResult' is not assignable to type 'SearchResult[]'. Property 'includes' is missing in type 'SearchResult'.' at: '28,5' source: 'ts' code: '2322'