TAK
TAK

Reputation: 11

cannot import the package aws-sdk on vue.js v3

I have a login.vue file (v3.11) to put ID information to User pool on AWS. But it cannot read CognitoUserPool. Installed version of aws-sdk is aws sdk 2.524.

I referred to the aws cognito docs. And what I wrote was as follows.

Examples: Using the JavaScript SDK

import { AmazonCognitoIdentity } from 'aws-sdk'

const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);

var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails(_this.authenticationData);

Error message:

Login.vue?7463:121 Uncaught TypeError: Cannot read property 'CognitoUserPool' of undefined

Upvotes: 1

Views: 1016

Answers (1)

D Malan
D Malan

Reputation: 11464

The Cognito Identity SDK was moved to the AWS Amplify package, so you would need to install that instead of the AWS SDK for JavaScript.

There's a small note on about it on this page, but it's admittedly not very prominent:

The Amazon Cognito Identity SDK for JavaScript is now part of the AWS Amplify Library.

After installing Amplify, should be able to create a new user pool like this:

import { CognitoUserPool } from 'amazon-cognito-identity-js'

const userPool = new CognitoUserPool(poolData);

Upvotes: 1

Related Questions