File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments