amplify-js: Error updating user attributes
I am following the docs:
let profile = await Auth.currentUserInfo();
let result = await Auth.updateUserAttributes(profile, {
'foo': 'bar'
});
And getting this error: TypeError: user.getSession is not a function. Indeed the object returned from Auth.currentUserInfo() does not have a getSession() function.
I am using aws-amplify version 0.2.2.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16 (4 by maintainers)
Commits related to this issue
- Docs fix for user attributes (#240) * fix docs #238 — committed to aws-amplify/amplify-js by mlabieniec 9 years ago
- Docs/update hocs (#251) * update quickstart * update docs index with examples * Update index.md * fix retrieve unauth credentials if not logged in, Fixes #229 * fix docs #238 * update ... — committed to aws-amplify/amplify-js by mlabieniec 9 years ago
@navjotdhanawat @j0b0sapi3n
Sorry for the late response… I’m using this code with Amplify 0.3.3:
Inspecting the source I found that the correct code might by:
It seems that just the docs need an update.
Thanks, @vipseixas. My biggest issue has been finding the right documentation. After a lot of searching, I still have not found an actual code example from AWS on the right way to update user attributes. This link has some guidance, but not an actual example.
Session: null attributes: Object { “custom:document_id”: “xx”, “custom:dept_id”: “xxx”, “custom:institution_id”: “xxxx”} authenticationFlowType: “USER_SRP_AUTH”
TypeError: user.getSession is not a function
It seems to be because the Session value in the CognitoUser object that is returned from currentAuthenticatedUser() is null
Please help me to fix this…
@navjotdhanawat I had the same issues with the 0.3.4, installing the latest version fix the problem for me
By inspecting the source, I realized something and wanted to to point it out in case others would need it.
Currently, the docs says that you can retrieve userAttributes like this:
But this doesn’t return the User Attributes directly. You then need to make another call like this: