0

I have some doubts on my code. The code below is my code.

import  {JwtHelperService}  from '@auth0/angular-jwt';
angular.module("appFoco", []).controller("LoginFormPDF", ['$scope', '$location', '$http', function($scope, $location, $http) {
const helper = new JwtHelperService();
console.log($scope);}])

And I want to fix this error => Uncaught SyntaxError: Unexpected token {

I am developing with angular and jwt and Nodejs. How I can fix this? Thanks

Ashish Ranjan
  • 12,760
  • 5
  • 27
  • 51
  • 1
    Possible duplicate of [How can I use an es6 import in node?](https://stackoverflow.com/questions/45854169/how-can-i-use-an-es6-import-in-node) – Seblor Mar 28 '19 at 13:02

1 Answers1

0

import {JwtHelperService} from '@auth0/angular-jwt';

This is the culprit here , By your code i can see you are using angularJS, For injecting a service in angularJS , you just have to do dependency injection in your controller.

You can't and dont't have to import it like this .

Just made a dependency injection like:

angular.module("appFoco", []).controller("LoginFormPDF", ['$scope', '$location', '$http', 'JwtHelperService', function($scope, $location, $http, JwtHelperService) {

And dont forget to add this service in index.html script section.

If you still wish to use import statement, you have to introduce a ES6 to ES5 compiler to compile your code before running it.

Shyam Tayal
  • 486
  • 2
  • 13