0

I try to use the AWS client scan the dynamoDB table.

I define a function as

var scan = (err, data) =>{}    

this couldn't work but when I write

function scan (err, data){}    

this work fine.

I don't understand why when I define the function with the arrow expression couldn't work, even inside the function, when I use forEach() or promise it all work fine in the same script.

mehulmpt
  • 15,861
  • 12
  • 48
  • 88
ckky1213
  • 321
  • 5
  • 14
  • When you say it doesn't work - were you seeing an error of some sort? Does your function perhaps make use of `this` within it? – James Thorpe May 04 '18 at 10:14
  • Probably you are using older version of NodeJS, try to use 6+, will work – Arif Khan May 04 '18 at 10:16
  • Might be your version of `Node.js`. [`Arrow function` support wasn't introduced until `v4`](https://stackoverflow.com/a/38241325/5566355) – Arman Charan May 04 '18 at 10:16
  • The function that is working is a syntax of ES6, You must be running with the old version of Node.js which doesn't support ES6 features, Try using latest Node.js or try using a transpiler like babel or something. – Sunil Lulla May 04 '18 at 11:48

1 Answers1

0

var nameOfTheFunction = (parameters) => { //code here }