developerforce / Force.com-JavaScript-REST-Toolkit

ForceTK - a minimal Force.com REST API for JavaScript apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

401 requests still has mis-typed variable and missing variable

elijahdorman opened this issue · comments

https://github.com/developerforce/Force.com-JavaScript-REST-Toolkit/blob/master/forcetk.js#L273

forcetk.Client.prototype.blob = function(path, fields, filename, payloadField, payload, callback, error, retry) {

https://github.com/developerforce/Force.com-JavaScript-REST-Toolkit/blob/master/forcetk.js#L315

that.blob(path, fields, filename, file, callback, error, true);

When a 401 occurs, it throws because file doesn't exist. If file happens to exist in another scope, then it passes the callback to the server (as data). Even worse, because true is passed as the error variable, it can continue infinitely because retry will always be undefined.

This kind of issue CANNOT occur if builds are being linted before distribution.

You're absolutely right. I just ran JSLint on forcetk.js and fixed all the errors/warnings.

And I just added a pre-commit script to avoid it happening again. Thanks again, @elijahdorman!