Fetching Data in Angular - Do It Correctly

Поделиться
HTML-код
  • Опубликовано: 24 янв 2025

Комментарии • 47

  • @MonsterlessonsAcademy
    @MonsterlessonsAcademy  4 года назад +1

    WATCH NEXT: Angular Interview Questions and Answers - Dominate Your Next Interview - ruclips.net/video/5A_YKlVWMPo/видео.htmlsi=2DCn7yspEAAJ2H6l

  • @trendytopics-
    @trendytopics- 3 года назад +1

    Very clear explanation, in short time, source code available, timestamps.
    A lot of helpful tutorials on this channel. THANK YOU SO MUCH FOR THIS! Subscribed!

  • @daviddmellul1398
    @daviddmellul1398 6 месяцев назад +1

    Hello , very clear explanation and tutorial. Will it work the same way in Angular 18 ? It seems that httpclient module obsolete . Any advice ? Thank you

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  6 месяцев назад +1

      Hi, yes it will. We still use Httpclient service in Angular 18 to get data. The only difference that we provide it in appConfig as provideHttpClient()

    • @daviddmellul1398
      @daviddmellul1398 6 месяцев назад

      Thanks , will try .

  • @americatoken3334
    @americatoken3334 2 года назад

    great explaination

  • @AnasandAmmar
    @AnasandAmmar Год назад

    Thanks for the video! I have a question, why you are not using fetch API? I have tried it, and it's working.

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  Год назад

      Fetch API is Javascript and is based on promises. Angular http is the core part of Angular and is based on Observables. I highly recommend you to stick to Angular approaches.

  • @TheHcobain
    @TheHcobain 2 года назад

    Hello, thanks for the tutorial, is it possible to run json server on github pages somehow?

  • @ananthakumarr537
    @ananthakumarr537 2 года назад

    Hi i have error
    No overload matches this call.
    Overload 1 of 3, '(observer?: Partial | undefined): Subscription', gave the following error.
    Type '(movies: Movie[]) => void' has no properties in common with type 'Partial'.

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  2 года назад

      Hi can you post your code?

    • @slowpoke1808
      @slowpoke1808 2 года назад +1

      Hey, idk is this still actual, but will be useful for those who will face this problem in the future. Rxjs changed from version 5 to version 6, HttpClientModule introduced serialized JSON support. So you can use Generic, like '.get'

  • @artworknataly
    @artworknataly 3 года назад

    Thank you very much for your video.

  • @AliRezaBabaei-e4o
    @AliRezaBabaei-e4o Год назад

    recently I can't use the type inside the subscription, why?

  • @amiga115
    @amiga115 3 года назад

    Thank you for the videos. I'm new to Angular and I think your teaching is very good. I have a question: you created the http variable in the constructor. What is the difference than creating it outside the constructor?

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  3 года назад +2

      I'm happy that you like my videos! It's not possible to create http variable outside or constructor arguments. It's a way how it is designed in Angular. Because it's not just "creating a variable". We inject dependency in our service or component.

  • @vamshi_travelling_life
    @vamshi_travelling_life 2 года назад

    Can we deploy angular app with json server
    Will json server api's work after deployment

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  2 года назад

      Yes sure. It's just a node process. Just run it like locally and it will work. But this is not a production solution of course.

  • @studentlearninginformatic4097
    @studentlearninginformatic4097 2 года назад

    wich app use for coding ?

  • @serhiitachuk
    @serhiitachuk 4 года назад

    Is it iTerm or default Mac OS terminal?

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  4 года назад

      Nope. And by the way I don't use Iterm anymore. As I don't need 90% of features that iterm2 has because of tmux I switched to alacritty which works much faster and easier to configure.

    • @serhiitachuk
      @serhiitachuk 4 года назад

      @@MonsterlessonsAcademy can u create a video about your setup?

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  4 года назад +1

      @@serhiitachuk Later for sure but now I'm trying to get more subscribers and I don't think that this video will be too popular.

  • @vamshi_travelling_life
    @vamshi_travelling_life 2 года назад

    Can we deploy angular app with json server
    Will json server api's work after deployment
    Please reply if u have any idea

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  2 года назад

      Yes sure. It's just a node process. Just run it like locally and it will work. But this is not a production solution of course.

  • @nipunachathuranga7493
    @nipunachathuranga7493 3 года назад

    Thanks Bro

  • @HM_Milan
    @HM_Milan 3 года назад

    Thank you

  • @andrewkhar4615
    @andrewkhar4615 8 месяцев назад

    Спасибо. Но есть ли где на русском вещаешь?

  • @adelkedjour
    @adelkedjour 3 года назад

    Thanks a lot for this videos, just a feedback, I think you need just to speed up a bit when you talk because you are really speaking too slow where it makes me sleep. (Please don't understand me wrong)

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  3 года назад +1

      Thanks for the feedback. I know about this problem but as English not my native language it's tricky. As a quick fix I can recommend watching my videos on 1.25x speed. People write that it's more comfortable.

    • @webinatic216
      @webinatic216 3 года назад +4

      @@MonsterlessonsAcademy I like the speed of your speech. I understand every word and can follow.

  • @SyahirahFaizal
    @SyahirahFaizal 2 года назад

    Hi I have an error here :
    Error: src/app/app.component.ts:19:18 - error TS2769: No overload matches this call.
    Overload 1 of 3, '(observer?: Partial | undefined): Subscription', gave the following error.
    Type '(users: UserInterface[]) => void' has no properties in common with type 'Partial'.
    Overload 2 of 3, '(next: (value: Object) => void): Subscription', gave the following error.
    Argument of type '(users: UserInterface[]) => void' is not assignable to parameter of type '(value: Object) => void'.
    Types of parameters 'users' and 'value' are incompatible.
    The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
    Type 'Object' is missing the following properties from type 'UserInterface[]': length, pop, push, concat, and 28 more.
    Overload 3 of 3, '(next?: ((value: Object) => void) | null | undefined, error?: ((error: any) => void) | null | undefined, complete?: (() => void) | null | undefined): Subscription', gave the following error.
    Argument of type '(users: UserInterface[]) => void' is not assignable to parameter of type '(value: Object) => void'.
    Types of parameters 'users' and 'value' are incompatible.
    Type 'Object' is not assignable to type 'UserInterface[]'.
    The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
    19 .subscribe((users: UserInterface[]) => {
    helpp :((

  • @adeshadhau643
    @adeshadhau643 3 года назад

    how to unit test json file data having multiple id's of users in angular ?
    user.json =>
    [
    {
    "id": "123",
    "email": "@sdafs.com",
    "isActive": "tru
    },
    {
    "id": "234",
    "email": "@kjsdk.com",
    "isActive": false
    }
    ]
    specs.ts=>
    it("should be",()=>{
    expect(???????).tobe(??????)})
    I have used httpclient method as you are doing in this video,but I have to do unit testing of user data present in json file, can you help me ?

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  3 года назад

      I can't answer it in several lines. Testing is quite a bit topic
      Here is a good article about how to mock and test httpClient
      blog.angulartraining.com/how-to-write-unit-tests-for-angular-code-that-uses-the-httpclient-429fa782eb15