Preview:
//Method before error
loadRewardTypes(): void {
    this.rewardTypeService.getAllRewardTypes().subscribe((rewardTypes: RewardTypeViewModel[]) => {
      this.rewardTypes = rewardTypes;
      this.filteredRewardTypes = rewardTypes;
    });
  }
  
//Method after error
loadRewardTypes(): void {
    this.rewardTypeService.getAllRewardTypes().subscribe({
      next: (rewardTypes: RewardTypeViewModel[]) => {
        console.log('API Response:', rewardTypes); // Check if the data is an array
        this.rewardTypes = Array.isArray(rewardTypes) ? rewardTypes : [];
        this.filteredRewardTypes = this.rewardTypes;
        console.log('Assigned rewardTypes:', this.rewardTypes); // Confirm assignment
      },
      error: (error) => {
        console.error('Error loading reward types:', error);
      }
    });
  }
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter