DEV Community

Vuvu Videos πŸ‡ΏπŸ‡¦
Vuvu Videos πŸ‡ΏπŸ‡¦

Posted on

Api call does not show in developer console (Chrome)

Good Day Everyone ,

This is my first post in this forum , i am new to Angular.

i have a service that i created and it is defined like this
TrendingChannelsService.ts

import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http'; 
Enter fullscreen mode Exit fullscreen mode
@Injectable({
  providedIn: 'root'
})
export class TrendingChannelsService {

  constructor(private http:HttpClient) {} 

   GetChannels() :any
   {
      let url ="https://trovadating.com/TrovaTVApi/channels";

      return this.http.get<any>(url);

   }
}
Enter fullscreen mode Exit fullscreen mode

and i have imported the http namespace in the app.module.ts like this


import { HttpClientModule } from '@angular/common/http';

Enter fullscreen mode Exit fullscreen mode

and in the imports like this


  imports: [  
    BrowserModule, 
    FontAwesomeModule  ,**HttpClientModule**,
   RouterModule.forRoot(appRoutes)
  ], 
Enter fullscreen mode Exit fullscreen mode

and in my component i am using the service like this
trending.component.ts

import { TrendingChannelsService } from './services/TrendingChannelsService';
import { Component, OnInit } from '@angular/core';  
import { HttpClientModule } from '@angular/common/http';

@Component({
    selector: 'trending', 
    templateUrl: 'trending.component.html', 
    styleUrls:['osahan.scss','bootstrap.min.scss' ,
    'owl.carousel.scss','owl.theme.scss','live.scss','custom.scss','all.min.css' ]
})
export class trending  implements OnInit
{   
    data : any;

    constructor(private objchannel : TrendingChannelsService) 
    { 
    }


        ngOnInit()  
        { 
                    this.objchannel.GetChannels().subscribe((result: any)=>{

                      this.data = result;

                    console.warn("results", this.data);
                    console.log(result); 

             } );

            }


} 

Enter fullscreen mode Exit fullscreen mode

and for some reason i dont see anything logged in the developer console, i used both .log and warn but my browser(Chrome) dont show the returned data. if you can take the URL for the service you will see it will give json data back.

Thanks

Top comments (0)