@@ -8781,8 +8781,8 @@ _.extend(Promise.prototype, /** @lends AV.Promise.prototype */ {
87818781 */
87828782 resolve : function ( result ) {
87838783 if ( this . _resolved || this . _rejected ) {
8784- throw "A promise was resolved even though it had already been " +
8785- ( this . _resolved ? "resolved" : "rejected" ) + "." ;
8784+ throw new Error ( "A promise was resolved even though it had already been " +
8785+ ( this . _resolved ? "resolved" : "rejected" ) + "." ) ;
87868786 }
87878787 this . _resolved = true ;
87888788 this . _result = arguments ;
@@ -8821,8 +8821,8 @@ _.extend(Promise.prototype, /** @lends AV.Promise.prototype */ {
88218821 */
88228822 reject : function ( error ) {
88238823 if ( this . _resolved || this . _rejected ) {
8824- throw "A promise was rejected even though it had already been " +
8825- ( this . _resolved ? "resolved" : "rejected" ) + "." ;
8824+ throw new Promise ( "A promise was rejected even though it had already been " +
8825+ ( this . _resolved ? "resolved" : "rejected" ) + "." ) ;
88268826 }
88278827 this . _rejected = true ;
88288828 this . _error = error ;
@@ -10220,7 +10220,7 @@ const AVError = require('./error');
1022010220const AV = require ( './av' ) ;
1022110221const _ = require ( 'underscore' ) ;
1022210222
10223- const getServerURLPromise = new AVPromise ( ) ;
10223+ let getServerURLPromise ;
1022410224
1022510225// 服务器请求的节点 host
1022610226const API_HOST = {
@@ -10459,6 +10459,7 @@ const refreshServerUrlByRouter = () => {
1045910459} ;
1046010460
1046110461const setServerUrlByRegion = ( region = 'cn' ) => {
10462+ getServerURLPromise = new AVPromise ( ) ;
1046210463 // 如果用户在 init 之前设置了 APIServerURL,则跳过请求 router
1046310464 if ( AV . _config . APIServerURL ) {
1046410465 getServerURLPromise . resolve ( ) ;
@@ -10502,6 +10503,9 @@ const AVRequest = (route, className, objectId, method, dataObject = {}, sessionT
1050210503
1050310504 checkRouter ( route ) ;
1050410505
10506+ if ( ! getServerURLPromise ) {
10507+ return AVPromise . error ( new Error ( 'Not initialized' ) ) ;
10508+ }
1050510509 return getServerURLPromise . then ( ( ) => {
1050610510 const apiURL = createApiUrl ( route , className , objectId , method , dataObject ) ;
1050710511 return setHeaders ( sessionToken ) . then (
@@ -13160,7 +13164,7 @@ module.exports = {
1316013164 * Each engineer has a duty to keep the code elegant
1316113165**/
1316213166
13163- module . exports = 'js1.3.0 ' ;
13167+ module . exports = 'js1.3.1 ' ;
1316413168
1316513169} , { } ] } , { } , [ 28 ] ) ( 28 )
1316613170} ) ;
0 commit comments