0

I am learning Angular ngrx/store-effects. While handling effects with my file I am facing errors as below :

Error Message :

./src/app/recipes/Store/recipe.effects.ts:20:12 - Error: Module parse failed: Unexpected token (20:12)
File was processed with these loaders:
 * ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
 * ./node_modules/@ngtools/webpack/src/ivy/index.js
You may need an additional loader to handle the result of these loaders.
|                     });
|                 }),
>             ;
|         }), map((recipes) => { return new RecipesActions.SetRecipes(recipes); }));
|     }

Error: src/app/recipes/Store/recipe.effects.ts:25:18 - error TS1109: Expression expected.

25                  }),
                    ~




× Failed to compile.

I have provided my file. But I don't know what I am doing wrong. Kindly help me.

import { HttpClient } from '@angular/common/http';
import { Actions , ofType , Effect} from '@ngrx/effects';
import { switchMap } from 'rxjs';
import { map } from 'rxjs/operators'
import { Recipe } from '../recipe.model';
import * as RecipesActions from '../Store/recipe.actions';

export class RecipesEffects {

    @Effect()
    fetchRecipes = this.actions$.pipe(
        ofType(RecipesActions.FETCH_RECIPES),
        switchMap( () => {
            return this.http.get<Recipe[]>(
                'https://ng-course-recipe-book-65f10.firebaseio.com/recipes.json',
                ),
                map( (recipes :any ) => {
                    return recipes.map( (recipe:any ) => {
                      return {
                        ...recipe,
                        ingredients: recipe.ingredients ? recipe.ingredients : []
                      };
                    }); 
                  }),
                 }),
                 map( (recipes:any) => { return new RecipesActions.SetRecipes(recipes)})
    )

    constructor(private actions$ : Actions , private http: HttpClient){}
}
vijay s
  • 147
  • 1
  • 4
  • 15
  • I saw this page: https://stackoverflow.com/questions/52268320/module-parse-failed-unexpected-token – edjm Sep 06 '22 at 12:33

0 Answers0