首页 > 解决方案 > How to set aws amplify data in localStorage ReactJS

问题描述

I'm making ReactJS App powered by AWS Amplify framework.

I wanted to make custom signUp component. Everything works fine except that my localStorage is empty.

While I was using "withAuthenticator" method of authentication localStorage was full of data which was important for application to work, now its empty.

My question is: How to force aws amplify authentication to put authentication data into localstorage like it is doing in "withAuthenticator" method.

I include code of my signUp function.

Auth.signUp({
    username,
    password,
    attributes: {
        email,          
        phone_number 
    },
    validationData: []  
    })
    .then((data) => {
        console.log(data);
    })
    .catch(err => console.log(err));
}

标签: reactjsamazon-web-servicesaws-amplify

解决方案


You can also use Cache from aws-amplify https://aws-amplify.github.io/docs/js/cache


推荐阅读