Skip to content

Commit

Permalink
Pass in X-API-VERSION, Bugfix error handling for XHR requests
Browse files Browse the repository at this point in the history
  • Loading branch information
syrnick committed Jun 30, 2015
1 parent 93a80bd commit 37df0a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions lib/run_action_with_jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@ function runActionWithJQuery(base, method, path, queryParams, bodyData, callback

headers: {
'Authorization': 'Bearer ' + base._airtable._apiKey,
// TODO: uncomment when the server is fixed to allow this header:
//'X-API-VERSION': base._airtable._apiVersion
'X-API-VERSION': base._airtable._apiVersion
},
success: function(data, textStatus, jqXHR) {
callback(null, null, data);
},
error: function(jqXHR, textStatus) {
var error;
if(jqXHR.statusCode()===429 && !base._airtable._noRetryIfRateLimited){
setTimeout(function(){
if (jqXHR.status === 429 && !base._airtable._noRetryIfRateLimited) {
setTimeout(function() {
runActionWithJQuery(base, method, path, queryParams, bodyData, callback);
}, internalConfig.RETRY_DELAY_IF_RATE_LIMITED);
return;
}
error = base._checkStatusForError(jqXHR.statusCode(), jqXHR.respnoseText);
error = base._checkStatusForError(jqXHR.status, jqXHR.responseJSON);
callback(error);
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "airtable",
"version": "0.2.2",
"version": "0.2.3",
"homepage": "https://github.com/airtable/airtable.js",
"repository": "git://github.com/airtable/airtable.js.git",
"private": false,
Expand Down

0 comments on commit 37df0a3

Please sign in to comment.