Deze pagina is nog niet beschikbaar in uw eigen taal. We werken er hard aan om meer taalversies toe te voegen. Bedankt voor uw steun.

On this page
Help Center/ OBS BrowserJS SDK/ API Reference/ Initialization/ Result Returned via a Callback Function

Result Returned via a Callback Function

Updated on 2023-03-16 GMT+08:00

Description

ObsClient returns the results by using a callback function that contains two parameters in sequence: the exception information parameter and the SDK common result object parameter. If the exception information parameter in the callback function is not null, an error occurs during the API calling. Otherwise, the API calling is complete. In such conditions, you need to obtain the HTTP status code from the SDK common result object parameter to check whether the operation is successful.

Sample Code

obsClient.putObject({
       Bucket : 'bucketname',
       Key : 'objectkey',
       Body : 'Hello OBS'
}, function(err, result) {
       if(err){
              console.log('Error-->' + err);
       }else{
              if(result.CommonMsg.Status < 300){
                     if(result.InterfaceResult){
                         console.log('Operation Succeed');
                     }
              }else{
                     console.log('Code-->' + result.CommonMsg.Code); 
                     console.log('Message-->' + result.CommonMsg.Message);
                     console.log('HostId-->' + result.CommonMsg.HostId);
                     console.log('RequestId-->' + result.CommonMsg.RequestId);
              }
       }
});
Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback