@@ -136,9 +136,6 @@ const createApiUrl = (AV, route, className, objectId, method, dataObject) => {
136136
137137 let apiURL = AV . _config . APIServerURL ;
138138
139- // Test Data
140- apiURL = 'https://e1-api.leancloud.cn' ;
141-
142139 if ( apiURL . charAt ( apiURL . length - 1 ) !== '/' ) {
143140 apiURL += '/' ;
144141 }
@@ -192,7 +189,8 @@ const handleError = (AV, res) => {
192189 so API server response http status 410 and the param "location" for this case.
193190 */
194191 if ( res . statusCode === 410 ) {
195-
192+ cacheServerURL ( res . response . api_server , res . response . ttl ) ;
193+ promise . resolve ( res . response . location ) ;
196194 } else {
197195 let errorJSON = { code : - 1 , error : res . responseText } ;
198196 if ( res . response && res . response . code ) {
@@ -207,7 +205,7 @@ const handleError = (AV, res) => {
207205
208206 // Transform the error into an instance of AV.Error by trying to parse
209207 // the error string as JSON.
210- const error = AV . Error ( errorJSON . code , errorJSON . error ) ;
208+ const error = new AV . Error ( errorJSON . code , errorJSON . error ) ;
211209 promise . reject ( error ) ;
212210 }
213211 return promise ;
@@ -271,8 +269,10 @@ const init = (AV) => {
271269
272270 return setHeaders ( AV , sessionToken ) . then (
273271 headers => ajax ( method , apiURL , dataObject , headers )
274- . then ( null , ( res ) =>
275- handleError ( AV , res )
272+ . then (
273+ null ,
274+ res => handleError ( AV , res )
275+ . then ( location => ajax ( method , location , dataObject , headers ) )
276276 )
277277 ) ;
278278 } ;
0 commit comments