javascript - Async function not working -


I am using rades using nodes (nod_redis module) and am trying to wrap my recovery code for debugging and drought.

Trouble understanding why the following function 'is not working'

I am more than basic async with Javascript, so I do not think this is anything to do except JS.

It works fine, but it is very redundant when there is a cover:

  // asyncLoad (className, id, callback) {redisClient.hget (className) , Id, callback); } // execution asyncLoad ('person', 1234, function (error, res) {if (err) {console.log (err);} else {var obj = JSON.parse (res); console.log (obj) ;}});  

I thought that if I can do this it would be useful for debugging and repetition, but I am definitely doing something wrong ...

  // AsyncLoad2 (className, id, callback) {redisClient.hget (className, id, function (error, res, callback) {console.log (callback); if (error) {console.log (err) );} Else {var obj = JSON.parse (res); callback (obj);}}); } // execution asyncLoad2 ('person', 1234, function (obj) {// easy way to get a parsed object back with previously handled error}  

thanks advance Thank you! I know that it's really dealing with lame error, I'm not expecting it to be used all the time, only for select things, and especially during debugging.

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -