I'm having problems calling this API:
var api = (function() {
function randResponseFn(data, maxWaitSecs) {
return function(callback) {
var waitTime = maxWaitSecs * Math.random();
setTimeout(function() {
callback(data);
}, waitSecs);
}
}
return {
getUserInfo: randResponseFn({name: "Bobby Tables", id: 1}, 5 * 1000),
getUserFriends: randResponseFn([{name: "Inactive User", id:2}, {name: "Test User", id:3}],2 * 1000)
}
})();
So far I have this:
window.onload = function() {
var testObj = {
name: 'Testing This'
}
var output = api.getUserInfo(testObj);
alert(output);
}
But this error shows up in console: Uncaught ReferenceError: waitSecs is not defined
Any ideas?

New Topic/Question
Reply



MultiQuote





|