The parsing module encountered an error due to an unexpected } token, causing a failure in

Can anyone help me figure out why this error keeps occurring?

ERROR in ./login/loginController.js
Module parse failed: /Users/leon/Projects/admin/login/loginController.js Line 66: Unexpected token }
You may need an appropriate loader to handle this file type.
|             console.log('login failed!');
|         }
|     }
| }
|
 @ ./entry.js 16:22-59

This section pertains to my entry.js file

Below is the loginController code snippet (line 66 contains the last closing }):

var loginController = angular
    .module('loginController', [])
    .controller('LoginCtrl', LoginCtrl);

LoginCtrl.$inject = [
    '$rootScope',
    '$scope',
    '$location',
    '$timeout',
    'ApiFactory',
    'AUTH_EVENTS',
    'AuthFactory'];

function LoginCtrl(
    $rootScope,
    $scope,
    $location,
    $timeout,
    ApiFactory,
    AUTH_EVENTS,
    AuthFactory) {

    /** Initialize LoginCtrl scope */
    var vs = $scope;
        vs.login = login;

    $rootScope.$broadcast(AUTH_EVENTS.loginSuccess);

    $rootScope.$on(AUTH_EVENTS.notAuthenticated, function (event, data) {
        $rootScope.currentUser = null;
        $scope.currentUser     = null;
        AuthFactory.logout();
        $location.path('/login');
    });

    function login(credentials) {
        console.log('credentials',credentials);
        AuthFactory.login(credentials).then(function (user) {
            $rootScope.$broadcast(AUTH_EVENTS.loginSuccess);
            $scope.setCurrentUser(user);

            if (user.password_reset) {
                $location.path('/password');
            } else {
                $location.path('/tickers');
            }
        }, function () {
            // $scope.loginData.message = "Invalid Username/Password";
            $rootScope.$broadcast(AUTH_EVENTS.loginFailed);
            console.log('login failed!');
        }
    }
}

module.exports = loginController;

Answer №1

It seems like the problem lies in the line

AuthFactory.login(credentials).then(function (user) {
, as it appears that the closing parenthesis ) is missing at the end of this method call.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Implementing API calls in C# with the help of AngularJS

Hey there! I am currently accessing my API by using the code snippet below: $http.get('/api/controller/method?param=value'). then(function (response) { if (response.status == 200) { console.log(resp ...

Combining array elements into sets of n

I am facing a challenge with an array manipulation task. let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]; My goal is to divide this array into a specified number of smaller arrays such that each new array contains the same number of elements ...

Comparing jQuery AJAX with UpdatePanel

Our team is facing the challenge of dealing with a page containing an overwhelming amount of jQuery code (specifically around 2000 lines) that has become difficult to maintain. We are considering shifting some of this functionality to the server side for ...

jQuery's find method returns a null value

During my Ajax POST request, I encountered an issue where I wanted to replace the current div with the one received from a successful Ajax call: var dom; var target; $.ajax({ type: "POST", url: "http://127.0.0.1/participants", data: "actio ...

The HTML5 video will continue playing indefinitely as long as its readyState remains at 4

In my efforts to develop a personalized HTML5 video player that can handle live streaming, recording of live streams, and playing regular video files, I have run into an issue with creating a custom seeking bar. To achieve this, I implemented the following ...

The PHP application encountered an error when trying to use an object of the mysqli_result type as an array

In my section, I have a straightforward display of data sourced from the database. Upon clicking options like construction and selecting countries like Algeria, the displayed values are [251, 211,712]. Similarly, for selections like Power in Egypt, the ou ...

The scrollTop feature fails to function properly following an Axios response

I'm currently facing a challenge with creating a real-time chat feature using Laravel, Vue.js, Pusher, and Echo. The issue arises while implementing the following 3 methods: created() { this.fetchMessages(); this.group = $('#group') ...

What is the best way to increase the row spacing in an Ant Design Table?

I have a table with expandable rows in antd, and I am looking to add some vertical space between the rows. I've tried using the rowClassName property provided by antd, but it did not work as expected. I also attempted to use a custom component, but th ...

Ways to trigger a function once all elements have been successfully mounted

Currently, I am incorporating VueJS with the Vue Router and a JavaScript uniform module to enhance the appearance of select boxes, checkboxes, and other form elements by wrapping them in a new element for better styling options. How can I efficiently appl ...

Retrieval of targeted keywords within a given paragraph using JavaScript

Currently tackling a project in react native (JS based) where I'm tasked with identifying and extracting the names of hospitals from dynamic paragraphs sourced from the backend server. Traditional methods such as match(), includes(), and more aren&apo ...

What is the most effective way to remove or modify an element in an array when a button is clicked?

I've hit a roadblock because I'm uncertain about how to access and remove elements stored within an array, especially if the user wants to delete from the middle. In this scenario, using pop won't suffice as it removes from the end without c ...

The search function in Typeahead is not activating the API request while typing

Having some trouble implementing a typeahead search feature in my nodejs application with mysql. I can't seem to figure out what's wrong with my code. When I manually access http://localhost:5000/search?key=s, I'm able to see the results an ...

Tips for generating and invoking a promise within NodeJS

I have been attempting to access Firestore using a function I created that includes a collection variable. var fetchDataFromFirestore = function(collection, doc){ return promise = new Promise(function(resolve,reject){ //If doc param is null Quer ...

Utilize JavaScript to parse HTML content retrieved through AJAX requests

My current project involves writing JavaScript code, specifically a Chrome extension, that needs to: Retrieve the contents of a web page using AJAX. Extract specific content from the page by identifying certain elements within the HTML string and retriev ...

Refresh information in database seamlessly without the need to reload the entire

Big shoutout to Sandeepan for the amazing support I just received! Could someone please take a look at what I may have overlooked in this code snippet... <head> <script type="text/javascript" src="jquery-1.4.2.js"></script> <script t ...

Exploring the capabilities of xhr2 using pure javascript

Currently, I am attempting to utilize xhr2 in order to read through a json file. Despite my efforts in researching various methods to accomplish this task, none have proved successful thus far. The function featured below my require statements is the one t ...

Rails and Javascript: Partial does not retrieve data attribute, yet it is visible in the DOM

Trying to show the select field value for shipping costs below the field. Thanks to @Vasfed, using data attributes and JavaScript. However, the data attribute is visible in the DOM when the page loads but not in the returned data for the AJAX call when che ...

Creating an HTML element within an ion-slide that allows for horizontal scrolling

I am facing an issue with a HTML horizontal stripe that contains buttons which need to be scrolled horizontally inside of <ion-slide>. The user wants to swipe this horizontal list from right to left to reveal the next set of buttons. The problem aris ...

Unexpected next() error occurred

Currently, I am working on a project using node.js along with express and MongoDB. I have encountered an error that I cannot seem to understand. When I remove the next() function call, everything works perfectly fine. However, when I include next(), it tr ...

Add a selection of paths from a different package into the Router

Seeking a quick solution here. I have the following code snippet and I am looking to efficiently import a multitude of routes from my package. These routes should be managed by the package I am constructing. If I introduce a new page in the package (e.g., ...