javascript - Syntax error on async arrow function -


i following this example, on section of code...

const getapiandemit = async socket => {   try {     const res = await axios.get(       "https://api.darksky.net/forecast/put_your_api_key_here/43.7695,11.2558"     ); // getting data darksky     socket.emit("fromapi", res.data.currently.temperature); // emitting new message. consumed client   } catch (error) {     console.error(`error: ${error.code}`);   } }; 

i following error

d:\documents\js\socketio-server\app.js:42 const getapiandemit = async socket => {                         ^^^^^^ syntaxerror: unexpected identifier     @ createscript (vm.js:56:10)     @ object.runinthiscontext (vm.js:97:10)     @ module._compile (module.js:542:28)     @ object.module._extensions..js (module.js:579:10)     @ module.load (module.js:487:32)     @ trymoduleload (module.js:446:12)     @ function.module._load (module.js:438:3)     @ module.runmain (module.js:604:10)     @ run (bootstrap_node.js:389:7)     @ startup (bootstrap_node.js:149:9) ps d:\documents\js\socketio-server> 

you need upgrade node 7.6 (or higher) since async keyword wasn't supported in earlier versions. of right now, 6.11 lst version , 8.3 latest.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -