AWS | Using DynamoDB results in “ERROR TypeError: Cannot convert undefined or null to object”









up vote
0
down vote

favorite












Im trying to utilize AWS JS SDK in my Angular application.



Consider the following code:



import * as AWS from 'aws-sdk';
import Component, OnInit from '@angular/core';

declare let AWSCognito: any;

@Component(
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
)

export class AppComponent implements OnInit

private _dynamodb;

constructor()
AWS.config.region = 'eu-west-2'; // Region
AWS.config.credentials = new AWS.CognitoIdentityCredentials(
IdentityPoolId: 'eu-west-2:xxyyzz'
);
this._dynamodb = new AWS.DynamoDB.DocumentClient();


ngOnInit()
this._dynamodb.get(TableName: 'somename', Key: projectId: 123321, (err, data) =>
)




When the above code is executed the following error appears:



ERROR TypeError: Cannot convert undefined or null to object


I can see that it's this._dynamodb.get that makes the system crash.



Any idea what I'm doing wrong?



EDIT:



Full stack trace:



ERROR TypeError: Cannot convert undefined or null to object
at hasOwnProperty (<anonymous>)
at isEndpointDiscoveryApplicable (discover_endpoint.js:279)
at Request.discoverEndpoint (discover_endpoint.js:322)
at Request.callListeners (sequential_executor.js:102)
at Request.emit (sequential_executor.js:78)
at Request.emit (request.js:683)
at Request.transition (request.js:22)
at AcceptorStateMachine.runTo (state_machine.js:14)
at state_machine.js:26
at Request.<anonymous> (request.js:38)









share|improve this question























  • If you add logging of this._dynamodb to the constructor after initializing _dynamodb and in the ngOnInit() method before invoking get(), does it provide any clues?
    – jarmod
    Nov 10 at 15:33











  • @jarmod it provides no clues. I can console log the pointer to the function (console.log(this._dynamodb.get)) just above the function call
    – Vingtoft
    Nov 10 at 16:22










  • For what it's worth, a simplified version of this code (no Angular, no classes) getting Key: projectId: 123321 using the DocumentClient works just fine for me. Are you using up to date AWS SDK? Can you post the full stack trace?
    – jarmod
    Nov 10 at 16:37










  • See edit. I have other projects where similar code works just fine. I think it something to do with a upgrade in a node_module, but Im not sure. On think I really hate with Angular is how a project can break apart when a single node component is upgraded, it can be a real struggle to solve
    – Vingtoft
    Nov 10 at 16:41










  • I don't see the get call in the stack trace. Are you sure that the this._dynamodb.get() call is the culprit?
    – jarmod
    Nov 10 at 16:44














up vote
0
down vote

favorite












Im trying to utilize AWS JS SDK in my Angular application.



Consider the following code:



import * as AWS from 'aws-sdk';
import Component, OnInit from '@angular/core';

declare let AWSCognito: any;

@Component(
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
)

export class AppComponent implements OnInit

private _dynamodb;

constructor()
AWS.config.region = 'eu-west-2'; // Region
AWS.config.credentials = new AWS.CognitoIdentityCredentials(
IdentityPoolId: 'eu-west-2:xxyyzz'
);
this._dynamodb = new AWS.DynamoDB.DocumentClient();


ngOnInit()
this._dynamodb.get(TableName: 'somename', Key: projectId: 123321, (err, data) =>
)




When the above code is executed the following error appears:



ERROR TypeError: Cannot convert undefined or null to object


I can see that it's this._dynamodb.get that makes the system crash.



Any idea what I'm doing wrong?



EDIT:



Full stack trace:



ERROR TypeError: Cannot convert undefined or null to object
at hasOwnProperty (<anonymous>)
at isEndpointDiscoveryApplicable (discover_endpoint.js:279)
at Request.discoverEndpoint (discover_endpoint.js:322)
at Request.callListeners (sequential_executor.js:102)
at Request.emit (sequential_executor.js:78)
at Request.emit (request.js:683)
at Request.transition (request.js:22)
at AcceptorStateMachine.runTo (state_machine.js:14)
at state_machine.js:26
at Request.<anonymous> (request.js:38)









share|improve this question























  • If you add logging of this._dynamodb to the constructor after initializing _dynamodb and in the ngOnInit() method before invoking get(), does it provide any clues?
    – jarmod
    Nov 10 at 15:33











  • @jarmod it provides no clues. I can console log the pointer to the function (console.log(this._dynamodb.get)) just above the function call
    – Vingtoft
    Nov 10 at 16:22










  • For what it's worth, a simplified version of this code (no Angular, no classes) getting Key: projectId: 123321 using the DocumentClient works just fine for me. Are you using up to date AWS SDK? Can you post the full stack trace?
    – jarmod
    Nov 10 at 16:37










  • See edit. I have other projects where similar code works just fine. I think it something to do with a upgrade in a node_module, but Im not sure. On think I really hate with Angular is how a project can break apart when a single node component is upgraded, it can be a real struggle to solve
    – Vingtoft
    Nov 10 at 16:41










  • I don't see the get call in the stack trace. Are you sure that the this._dynamodb.get() call is the culprit?
    – jarmod
    Nov 10 at 16:44












up vote
0
down vote

favorite









up vote
0
down vote

favorite











Im trying to utilize AWS JS SDK in my Angular application.



Consider the following code:



import * as AWS from 'aws-sdk';
import Component, OnInit from '@angular/core';

declare let AWSCognito: any;

@Component(
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
)

export class AppComponent implements OnInit

private _dynamodb;

constructor()
AWS.config.region = 'eu-west-2'; // Region
AWS.config.credentials = new AWS.CognitoIdentityCredentials(
IdentityPoolId: 'eu-west-2:xxyyzz'
);
this._dynamodb = new AWS.DynamoDB.DocumentClient();


ngOnInit()
this._dynamodb.get(TableName: 'somename', Key: projectId: 123321, (err, data) =>
)




When the above code is executed the following error appears:



ERROR TypeError: Cannot convert undefined or null to object


I can see that it's this._dynamodb.get that makes the system crash.



Any idea what I'm doing wrong?



EDIT:



Full stack trace:



ERROR TypeError: Cannot convert undefined or null to object
at hasOwnProperty (<anonymous>)
at isEndpointDiscoveryApplicable (discover_endpoint.js:279)
at Request.discoverEndpoint (discover_endpoint.js:322)
at Request.callListeners (sequential_executor.js:102)
at Request.emit (sequential_executor.js:78)
at Request.emit (request.js:683)
at Request.transition (request.js:22)
at AcceptorStateMachine.runTo (state_machine.js:14)
at state_machine.js:26
at Request.<anonymous> (request.js:38)









share|improve this question















Im trying to utilize AWS JS SDK in my Angular application.



Consider the following code:



import * as AWS from 'aws-sdk';
import Component, OnInit from '@angular/core';

declare let AWSCognito: any;

@Component(
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
)

export class AppComponent implements OnInit

private _dynamodb;

constructor()
AWS.config.region = 'eu-west-2'; // Region
AWS.config.credentials = new AWS.CognitoIdentityCredentials(
IdentityPoolId: 'eu-west-2:xxyyzz'
);
this._dynamodb = new AWS.DynamoDB.DocumentClient();


ngOnInit()
this._dynamodb.get(TableName: 'somename', Key: projectId: 123321, (err, data) =>
)




When the above code is executed the following error appears:



ERROR TypeError: Cannot convert undefined or null to object


I can see that it's this._dynamodb.get that makes the system crash.



Any idea what I'm doing wrong?



EDIT:



Full stack trace:



ERROR TypeError: Cannot convert undefined or null to object
at hasOwnProperty (<anonymous>)
at isEndpointDiscoveryApplicable (discover_endpoint.js:279)
at Request.discoverEndpoint (discover_endpoint.js:322)
at Request.callListeners (sequential_executor.js:102)
at Request.emit (sequential_executor.js:78)
at Request.emit (request.js:683)
at Request.transition (request.js:22)
at AcceptorStateMachine.runTo (state_machine.js:14)
at state_machine.js:26
at Request.<anonymous> (request.js:38)






typescript amazon-web-services amazon-dynamodb






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 16:40

























asked Nov 10 at 15:03









Vingtoft

3,52843150




3,52843150











  • If you add logging of this._dynamodb to the constructor after initializing _dynamodb and in the ngOnInit() method before invoking get(), does it provide any clues?
    – jarmod
    Nov 10 at 15:33











  • @jarmod it provides no clues. I can console log the pointer to the function (console.log(this._dynamodb.get)) just above the function call
    – Vingtoft
    Nov 10 at 16:22










  • For what it's worth, a simplified version of this code (no Angular, no classes) getting Key: projectId: 123321 using the DocumentClient works just fine for me. Are you using up to date AWS SDK? Can you post the full stack trace?
    – jarmod
    Nov 10 at 16:37










  • See edit. I have other projects where similar code works just fine. I think it something to do with a upgrade in a node_module, but Im not sure. On think I really hate with Angular is how a project can break apart when a single node component is upgraded, it can be a real struggle to solve
    – Vingtoft
    Nov 10 at 16:41










  • I don't see the get call in the stack trace. Are you sure that the this._dynamodb.get() call is the culprit?
    – jarmod
    Nov 10 at 16:44
















  • If you add logging of this._dynamodb to the constructor after initializing _dynamodb and in the ngOnInit() method before invoking get(), does it provide any clues?
    – jarmod
    Nov 10 at 15:33











  • @jarmod it provides no clues. I can console log the pointer to the function (console.log(this._dynamodb.get)) just above the function call
    – Vingtoft
    Nov 10 at 16:22










  • For what it's worth, a simplified version of this code (no Angular, no classes) getting Key: projectId: 123321 using the DocumentClient works just fine for me. Are you using up to date AWS SDK? Can you post the full stack trace?
    – jarmod
    Nov 10 at 16:37










  • See edit. I have other projects where similar code works just fine. I think it something to do with a upgrade in a node_module, but Im not sure. On think I really hate with Angular is how a project can break apart when a single node component is upgraded, it can be a real struggle to solve
    – Vingtoft
    Nov 10 at 16:41










  • I don't see the get call in the stack trace. Are you sure that the this._dynamodb.get() call is the culprit?
    – jarmod
    Nov 10 at 16:44















If you add logging of this._dynamodb to the constructor after initializing _dynamodb and in the ngOnInit() method before invoking get(), does it provide any clues?
– jarmod
Nov 10 at 15:33





If you add logging of this._dynamodb to the constructor after initializing _dynamodb and in the ngOnInit() method before invoking get(), does it provide any clues?
– jarmod
Nov 10 at 15:33













@jarmod it provides no clues. I can console log the pointer to the function (console.log(this._dynamodb.get)) just above the function call
– Vingtoft
Nov 10 at 16:22




@jarmod it provides no clues. I can console log the pointer to the function (console.log(this._dynamodb.get)) just above the function call
– Vingtoft
Nov 10 at 16:22












For what it's worth, a simplified version of this code (no Angular, no classes) getting Key: projectId: 123321 using the DocumentClient works just fine for me. Are you using up to date AWS SDK? Can you post the full stack trace?
– jarmod
Nov 10 at 16:37




For what it's worth, a simplified version of this code (no Angular, no classes) getting Key: projectId: 123321 using the DocumentClient works just fine for me. Are you using up to date AWS SDK? Can you post the full stack trace?
– jarmod
Nov 10 at 16:37












See edit. I have other projects where similar code works just fine. I think it something to do with a upgrade in a node_module, but Im not sure. On think I really hate with Angular is how a project can break apart when a single node component is upgraded, it can be a real struggle to solve
– Vingtoft
Nov 10 at 16:41




See edit. I have other projects where similar code works just fine. I think it something to do with a upgrade in a node_module, but Im not sure. On think I really hate with Angular is how a project can break apart when a single node component is upgraded, it can be a real struggle to solve
– Vingtoft
Nov 10 at 16:41












I don't see the get call in the stack trace. Are you sure that the this._dynamodb.get() call is the culprit?
– jarmod
Nov 10 at 16:44




I don't see the get call in the stack trace. Are you sure that the this._dynamodb.get() call is the culprit?
– jarmod
Nov 10 at 16:44

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240222%2faws-using-dynamodb-results-in-error-typeerror-cannot-convert-undefined-or-nu%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240222%2faws-using-dynamodb-results-in-error-typeerror-cannot-convert-undefined-or-nu%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3