Skip to content

Commit ac682d7

Browse files
committed
[fix] AV._request not working in React Native.
1 parent a19c758 commit ac682d7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/promise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ _.extend(Promise, /** @lends AV.Promise */ {
7878
*/
7979
as: function() {
8080
var promise = new Promise();
81-
if (_.isFunction(arguments[0])) {
81+
if (arguments[0] && _.isFunction(arguments[0].then)) {
8282
arguments[0].then(function(data) {
8383
promise.resolve.call(promise, data);
8484
}, function(err) {

lib/utils.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,14 @@ module.exports = function(AV) {
415415
dataObject._MasterKey = AV.masterKey;
416416
dataObject._ClientVersion = AV.VERSION;
417417
// Pass the session token on every request.
418-
var currentUser = AV.User.current();
419-
if (currentUser && currentUser._sessionToken) {
420-
dataObject._SessionToken = currentUser._sessionToken;
421-
}
422-
423-
return AV._getInstallationId().then(function(_InstallationId) {
418+
return AV.User.currentAsync().then(function(currentUser) {
419+
if (currentUser && currentUser._sessionToken) {
420+
dataObject._SessionToken = currentUser._sessionToken;
421+
}
422+
return AV._getInstallationId();
423+
}).then(function(_InstallationId) {
424424
dataObject._InstallationId = _InstallationId;
425-
}).then(function() {
425+
426426
var data = JSON.stringify(dataObject);
427427
return AV._ajax(method, url, data).then(null, function(response) {
428428
// Transform the error into an instance of AV.Error by trying to parse

0 commit comments

Comments
 (0)