Skip to content
Advertisement

Cannot push to DynamoDB without the inclusion of a certain value

I want to push some data from a form to DynamoDB for storage. If I include data for nutrients, this all works swimmingly. When I exclude nutrients, for some reason the push fails.

I want this to work with any of these values missing except recipe_index and item_type (recipe_index is auto-generated from a query at the top of the script; item_type is manually set to {S: 'recipe'}).

There is nothing I see to make it work conditional to nutrients’s availability. My only clue is a generic log of Error RequestAbortedError: Request aborted. I have tried to move around and simplify this code in the process to troubleshoot it; to no avail. Googling was no luck either. I usually find something on an error message…

My hope is one of you fine Internet strangers can save me from my own stupidity as I am sure I am overlooking something that should be obvious. I am still pretty new to DynamoDB, JS, and React.

JavaScript

Advertisement

Answer

You cannot save a value as undefined, which is happening when you do not define nutrients.

Try and conditionally set nutrients

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement