Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Trouble using AWS Javascript SDK with QML (Undefined).



  • I'm attempting to utilize the AWS Javascript SDK in a Qt Quick project. Specifically the AWS Cognito User Pools.

    I'm importing the SDK like this:

    import "aws-sdk.js" as AWS
    ... //Later Calling like this
    var userPool = new AWS.AmazonCognitoIdentity.CognitoUserPool(poolData);
    

    Receiving an error:TypeError: Cannot read property 'CognitoUserPool' of undefined

    I added the aws-sdk.js by using add existing file from Qt Creator and selecting the file which is in the source directory. Is there something else I need to do to enable the use of the SDK?



  • Does that code assume it is running in a web browser? It may be expecting a DOM to be available as well as other common objects that browsers support. Are you sure that Qt JS is compatible? You may need to go through the AWS code and see if it relies on anything specific to browsers.



  • It’s quite possible as AWS does have two versions of the JavaScript SDK. One for browsers and 1 for NodeJS. Thanks, I will dig into this.


Log in to reply