Issue encountered with asynchronous execution while utilizing AWS Cognito registration process

I am developing a user management system using Amazon Web Services called Cognito.

Everything works fine locally, but I encounter issues when running it on a Wamp server.

I cannot seem to pinpoint the cause... could it be due to asynchronous execution?

In my controller, I am using $q and .then(function() { ... }); to ensure proper execution.

Here is how I implement it in my controller:

  $scope.validateForm = function() {
         if (AuthService.getActifUser() == false) {
             //clear local storage
             $storage.remove('userData');
         }
         //getting the form attributes
         var datafirstName = {
             Name: 'custom:first_name',
             Value: $scope.firstName
         };
         var dataLastName = {
            Name: 'custom:last_name',
            Value: $scope.lastName
         };
         var dataEmail = {
            Name: 'email',
            Value: $scope.email
         };
         var attributeFirstName = AuthService.setAttributes(datafirstName);
         var attributeLastName = AuthService.setAttributes(dataLastName);
         var attributeEmail = AuthService.setAttributes(dataEmail);
         var attributeList = [];
         attributeList.push(attributeFirstName);
         attributeList.push(attributeLastName);
         attributeList.push(attributeEmail);
         // signing try
         AuthService.signin($scope.username, $scope.password, attributeList)
         .then(function(res) {
             // save username in local storage
             $storage.set('userData', $scope.username);
             // go to the verification page
             routeService.goToView('/users-confirmation');
       }, function(res) {
          console.log(res);
       );
     }

And in the AuthService Factory:

  AuthService.signin = function(username, password, attributeList) {
        var deferred = $q.defer();
        userPool.signUp(username, password, attributeList, null, function(err, result) {
             if (err) {
                alert(err);
                deferred.reject('registering failed.');
             }
             console.log('successfully registered.');
             deferred.resolve('successfully registered.');
         });
         return deferred.promise;
      };

Unfortunately, the routeService.goToView() method is never triggered.

I hope someone can provide insight into why this might be happening.

Answer №1

Is it possible to include a promise rejection handler for preventing the rejection of promises?

There is a possibility that your promise is being rejected and the error is being concealed. Additionally, have you established where invalidPassword is defined?

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 route prefix in a combination of express and react deployment

I'm currently facing a challenge while trying to deploy a react app that utilizes router functionality with express. The react app is expected to be accessible via the /dashboard route. At first glance, everything seems to be working smoothly on the ...

What is the best way to keep the heights of two divs in sync?

Is there a way to make two divs have the same height, even though their content determines their individual heights? I am looking for a solution that doesn't involve using a table or a parent div. I'm new to JavaScript, so I'm hoping there i ...

Trigger the execution of the second function upon the successful completion of the first

In the following code, my concept is to display: The clicked kingdom (clicked_id) initiates an attack on (clicked_id). https://i.stack.imgur.com/Bx8QW.png https://i.stack.imgur.com/Cg2GL.png https://i.stack.imgur.com/gUNxM.png How can I trigger the sec ...

Achieving asynchronous results in the parent function with TypeScript: a guide

The code structure provided is as follows: import {socket} from './socket'; class A{ Execute(...args[]){ //logic with Promises SomeAsyncMethod1().then(fulfilled1); function fulfilled1(){ SomeAsyncMethod2(args).then(fulfilled2); ...

"When I use breakpoints and run my application in debugging mode, it performs flawlessly. However, without these tools, it

I have developed an application using the Ionic Framework with Firebase as the backend. When I run the application with breakpoints using the debugger, everything works fine. However, if I run it without the debugger, I notice that values are not being upd ...

Tips for updating the data value of a specific block using Vue.js

I am looking to develop a basic Vue.js application. Within this app, I have multiple counter blocks that are rendered using the v-for directive. In my data object, I initialize a 'counter: 0' instance. My goal is to increment and decrement only o ...

Attempting to integrate a three.js OBJLoader within an HTML canvas

My issue is quite straightforward: I attempted to connect a three.js script with an HTML canvas, but I was unsuccessful and now I'm unsure how to proceed. Here is the code I have (I've already loaded the necessary scripts in the HTML head): wi ...

Retrieve the chosen option index using AngularJS

It is common knowledge that a select list can have multiple options, each starting from [0]. For example: [0]<option>E.U</option> [1]<option>India</option> [2]<option>Peru</option> In my Angular application, I am using ...

What are effective ways to eliminate script tags from a webpage?

I have implemented tags on my website that users can use to interact with the site. My goal is to figure out how to make the browser only read text from a specific file I write, without any HTML. This should be restricted to certain sections of my websit ...

Vue seems to be experiencing some difficulty displaying the data

I am facing an issue with loading data from firestore asynchronously. Although I can see the data in the log, Vue is only displaying the initial value before the data is loaded. I have tried calling the loading method both using beforeMount() and from a c ...

``There Seems to be an Issue with Loading Content in Tabs

Hey! I'm encountering an issue with my jquery tabs. The first tab content loads fine, but when I select another tab, the content doesn't display. Then, when I try to go back to the first tab, it doesn't load either. Here's the HTML cod ...

SEO Optimized pagination for pages without modifying the URL

On my website, I utilize pagination to navigate to various event pages. However, search engines are not picking up the conferences on these pages. Take a look at the code snippet below... <a href="javascript:;" class="first" title="First" onclick="getC ...

ClickAwayListener is preventing the onClick event from being fired within a component that is nested

I am encountering an issue with the clickAwayListener feature of material-ui. It seems to be disabling the onClick event in one of the buttons on a nested component. Upon removing the ClickAwayListener, everything functions as expected. However, with it e ...

Fetching json data from the request in Node.js

I'm currently working on a project that involves using the request module to send an HTTP GET request to a specific URL in order to receive a JSON response. However, I've run into an issue where my function is not properly returning the body of ...

How can I open the Ion-datetime view for the current year without allowing the selection of a specific day?

I am currently troubleshooting an issue with an Ionic date-time picker component. Upon opening the datepicker, it defaults to showing May 2021. As I scroll to the present date, I notice a circle highlighting today's date indicating that it selects th ...

Positioning Images in Tailwind Modals

I'm currently working on building a modal using Tailwind in Vue, but I've run into some challenges with aligning the elements inside the modal as desired. I've experimented with removing certain Tailwind classes and have tried implementing ...

Ways to conceal the current state changes from being displayed in the URL

I've implemented a React form with text fields and radio buttons to store data in the state. The 'Proceed' button triggers an onClick function: handleClick(event){ console.log(this.state); var userID = 1; firebase.database().ref ...

Local directory system for organizing users' files and folders

My website is built using mean-stack technology. I utilize the File System to create folders and write files on servers. Here is an example of the backend code: router.post('/httpOnly/mkdir', function (req, res, next) { var fs = require(&apo ...

Is there a way to ensure that a method is always called in JavaScript after JQuery has finished loading

We recently integrated jquery load into our website to dynamically load content into a div without refreshing the whole page. However, we've noticed that in the complete function, we have to constantly re-apply various bindings. Is there a way to set ...

Make the table in a bootstrap design appear with a border when you hover over a cell using the table

Looking for a solution to make the border work as expected when hovering over each td in a table like this example: https://jsfiddle.net/nmw82od1/ Here is the CSS code: .table1 td:hover { border: 1px solid black; } .table2 td:hover { border: 1px do ...