1# @ohos.app.form.formProvider (formProvider) 2 3The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release. 4 5> **NOTE** 6> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 7 8## Modules to Import 9 10```ts 11import formProvider from '@ohos.app.form.formProvider'; 12``` 13 14## setFormNextRefreshTime 15 16setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void 17 18Sets the next refresh time for a widget. This API uses an asynchronous callback to return the result. 19 20**System capability**: SystemCapability.Ability.Form 21 22**Parameters** 23 24| Name| Type | Mandatory| Description | 25| ------ | ------ | ---- | ------------------------------------- | 26| formId | string | Yes | Widget ID. | 27| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. | 28| callback | AsyncCallback<void> | Yes| Callback used to return the result.| 29 30**Error codes** 31 32| Error Code ID| Error Message| 33| -------- | -------- | 34| 401 | If the input parameter is not valid parameter. | 35| 16500050 | An IPC connection error happened. | 36| 16500060 | A service connection error happened, please try again later. | 37| 16500100 | Failed to obtain the configuration information. | 38| 16501000 | An internal functional error occurred. | 39| 16501001 | The ID of the form to be operated does not exist. | 40| 16501002 | The number of forms exceeds upper bound. | 41| 16501003 | The form can not be operated by the current application. | 42 43For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md). 44 45**Example** 46 47```ts 48import Base from '@ohos.base'; 49 50let formId: string = '12400633174999288'; 51try { 52 formProvider.setFormNextRefreshTime(formId, 5, (error: Base.BusinessError) => { 53 if (error) { 54 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 55 return; 56 } 57 console.log(`formProvider setFormNextRefreshTime success`); 58 }); 59} catch (error) { 60 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 61} 62``` 63 64## setFormNextRefreshTime 65 66setFormNextRefreshTime(formId: string, minute: number): Promise<void> 67 68Sets the next refresh time for a widget. This API uses a promise to return the result. 69 70**System capability**: SystemCapability.Ability.Form 71 72**Parameters** 73 74| Name| Type | Mandatory| Description | 75| ------ | ------ | ---- | ------------------------------------- | 76| formId | string | Yes | Widget ID. | 77| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. | 78 79**Return value** 80 81| Type | Description | 82| ------------- | ---------------------------------- | 83| Promise\<void> | Promise that returns no value. | 84 85**Error codes** 86 87| Error Code ID| Error Message| 88| -------- | -------- | 89| 401 | If the input parameter is not valid parameter. | 90| 16500050 | An IPC connection error happened. | 91| 16500060 | A service connection error happened, please try again later. | 92| 16500100 | Failed to obtain the configuration information. | 93| 16501000 | An internal functional error occurred. | 94| 16501001 | The ID of the form to be operated does not exist. | 95| 16501002 | The number of forms exceeds upper bound. | 96| 16501003 | The form can not be operated by the current application. | 97 98For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md). 99 100**Example** 101 102```ts 103import Base from '@ohos.base'; 104 105let formId: string = '12400633174999288'; 106try { 107 formProvider.setFormNextRefreshTime(formId, 5).then(() => { 108 console.log(`formProvider setFormNextRefreshTime success`); 109 }).catch((error: Base.BusinessError) => { 110 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 111 }); 112} catch (error) { 113 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 114} 115``` 116 117## updateForm 118 119updateForm(formId: string, formBindingData: formBindingData.FormBindingData,callback: AsyncCallback<void>): void 120 121Updates a widget. This API uses an asynchronous callback to return the result. 122 123**System capability**: SystemCapability.Ability.Form 124 125**Parameters** 126 127| Name| Type | Mandatory| Description | 128| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 129| formId | string | Yes | ID of the widget to update.| 130| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. | 131| callback | AsyncCallback<void> | Yes| Callback used to return the result.| 132 133**Error codes** 134 135| Error Code ID| Error Message| 136| -------- | -------- | 137| 401 | If the input parameter is not valid parameter. | 138| 16500050 | An IPC connection error happened. | 139| 16500060 | A service connection error happened, please try again later. | 140| 16500100 | Failed to obtain the configuration information. | 141| 16501000 | An internal functional error occurred. | 142| 16501001 | The ID of the form to be operated does not exist. | 143| 16501003 | The form can not be operated by the current application. | 144 145For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md). 146 147**Example** 148 149```ts 150import formBindingData from '@ohos.app.form.formBindingData'; 151import Base from '@ohos.base'; 152 153let formId: string = '12400633174999288'; 154try { 155 let param: Record<string, string> = { 156 'temperature': '22c', 157 'time': '22:00' 158 } 159 let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(param); 160 formProvider.updateForm(formId, obj, (error: Base.BusinessError) => { 161 if (error) { 162 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 163 return; 164 } 165 console.log(`formProvider updateForm success`); 166 }); 167} catch (error) { 168 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 169} 170``` 171 172## updateForm 173 174updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise<void> 175 176Updates a widget. This API uses a promise to return the result. 177 178**System capability**: SystemCapability.Ability.Form 179 180**Parameters** 181 182| Name| Type | Mandatory| Description | 183| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 184| formId | string | Yes | ID of the widget to update.| 185| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. | 186 187**Return value** 188 189| Type | Description | 190| -------------- | ----------------------------------- | 191| Promise\<void> | Promise that returns no value.| 192 193**Error codes** 194 195| Error Code ID| Error Message| 196| -------- | -------- | 197| 401 | If the input parameter is not valid parameter. | 198| 16500050 | An IPC connection error happened. | 199| 16500060 | A service connection error happened, please try again later. | 200| 16500100 | Failed to obtain the configuration information. | 201| 16501000 | An internal functional error occurred. | 202| 16501001 | The ID of the form to be operated does not exist. | 203| 16501003 | The form can not be operated by the current application. | 204 205For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md). 206 207**Example** 208 209```ts 210import formBindingData from '@ohos.app.form.formBindingData'; 211import Base from '@ohos.base'; 212 213let formId: string = '12400633174999288'; 214let param: Record<string, string> = { 215 'temperature': '22c', 216 'time': '22:00' 217} 218let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(param); 219try { 220 formProvider.updateForm(formId, obj).then(() => { 221 console.log(`formProvider updateForm success`); 222 }).catch((error: Base.BusinessError) => { 223 console.error(`promise error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 224 }); 225} catch (error) { 226 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 227} 228``` 229 230## getFormsInfo 231 232getFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void 233 234Obtains the application's widget information on the device. This API uses an asynchronous callback to return the result. 235 236**System capability**: SystemCapability.Ability.Form 237 238**Parameters** 239 240| Name| Type | Mandatory| Description | 241| ------ | ------ | ---- | ------- | 242| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.| 243 244**Error codes** 245| Error Code ID| Error Message| 246| -------- | -------- | 247| 401 | If the input parameter is not valid parameter. | 248| 16500050 | An IPC connection error happened. | 249| 16500100 | Failed to obtain the configuration information. | 250| 16501000 | An internal functional error occurred. | 251 252For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md). 253 254 255**Example** 256 257```ts 258import Base from '@ohos.base'; 259 260try { 261 formProvider.getFormsInfo((error, data) => { 262 if (error) { 263 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 264 return; 265 } 266 console.log(`formProvider getFormsInfo, data: ${JSON.stringify(data)}`); 267 }); 268} catch (error) { 269 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 270} 271``` 272## getFormsInfo 273 274getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): void 275 276Obtains the application's widget information that meets a filter criterion on the device. This API uses an asynchronous callback to return the result. 277 278**System capability**: SystemCapability.Ability.Form 279 280**Parameters** 281 282| Name| Type | Mandatory| Description | 283| ------ | ------ | ---- | ------- | 284| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | Yes| Filter criterion.| 285| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.| 286 287**Error codes** 288 289| Error Code ID| Error Message| 290| -------- | -------- | 291| 401 | If the input parameter is not valid parameter. | 292| 16500050 | An IPC connection error happened. | 293| 16500100 | Failed to obtain the configuration information. | 294| 16501000 | An internal functional error occurred. | 295 296For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md). 297 298**Example** 299 300```ts 301import Base from '@ohos.base'; 302import formInfo from '@ohos.app.form.formInfo'; 303 304const filter: formInfo.FormInfoFilter = { 305 // get info of forms belong to module entry. 306 moduleName: 'entry' 307}; 308try { 309 formProvider.getFormsInfo(filter, (error, data) => { 310 if (error) { 311 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 312 return; 313 } 314 console.log(`formProvider getFormsInfo, data: ${JSON.stringify(data)}`); 315 }); 316} catch (error) { 317 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 318} 319``` 320 321## getFormsInfo 322 323getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.FormInfo>> 324 325Obtains the application's widget information on the device. This API uses a promise to return the result. 326 327**System capability**: SystemCapability.Ability.Form 328 329**Parameters** 330 331| Name| Type | Mandatory| Description | 332| ------ | ------ | ---- | ------- | 333| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | No| Filter criterion. By default, no value is passed, indicating that no filtering is performed.| 334 335**Return value** 336 337| Type | Description | 338| :------------ | :---------------------------------- | 339| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.| 340 341**Error codes** 342 343| Error Code ID| Error Message| 344| -------- | -------- | 345| 401 | If the input parameter is not valid parameter. | 346| 16500050 | An IPC connection error happened. | 347| 16500100 | Failed to obtain the configuration information. | 348| 16501000 | An internal functional error occurred. | 349 350For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md). 351 352**Example** 353 354```ts 355import formInfo from '@ohos.app.form.formInfo'; 356import Base from '@ohos.base'; 357 358const filter: formInfo.FormInfoFilter = { 359 // get info of forms belong to module entry. 360 moduleName: 'entry' 361}; 362try { 363 formProvider.getFormsInfo(filter).then((data: formInfo.FormInfo[]) => { 364 console.log(`formProvider getFormsInfo, data: ${JSON.stringify(data)}`); 365 }).catch((error: Base.BusinessError) => { 366 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 367 }); 368} catch (error) { 369 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 370} 371``` 372 373## requestPublishForm 374 375requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<string>): void 376 377Requests to publish a widget carrying data to the widget host (usually the home screen). This API uses an asynchronous callback to return the result. 378 379**System capability**: SystemCapability.Ability.Form 380 381**System API**: This is a system API. 382 383**Parameters** 384 385| Name| Type | Mandatory| Description | 386| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 387| want | [Want](js-apis-app-ability-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' | 388| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.| 389| callback | AsyncCallback<string> | Yes| Callback used to return the widget ID.| 390 391**Error codes** 392 393| Error Code ID| Error Message| 394| -------- | -------- | 395| 202 | The application is not a system application. | 396| 401 | If the input parameter is not valid parameter. | 397| 16500050 | An IPC connection error happened. | 398| 16500100 | Failed to obtain the configuration information. | 399| 16501000 | An internal functional error occurred. | 400 401For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md). 402 403**Example** 404 405```ts 406import formBindingData from '@ohos.app.form.formBindingData'; 407import Want from '@ohos.app.ability.Want'; 408import Base from '@ohos.base'; 409 410let want: Want = { 411 abilityName: 'FormAbility', 412 parameters: { 413 'ohos.extra.param.key.form_dimension': 2, 414 'ohos.extra.param.key.form_name': 'widget', 415 'ohos.extra.param.key.module_name': 'entry' 416 } 417}; 418try { 419 let param: Record<string, string> = { 420 'temperature': '22c', 421 'time': '22:00' 422 } 423 let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(param); 424 formProvider.requestPublishForm(want, obj, (error: Base.BusinessError, data: string) => { 425 if (error) { 426 console.error(`callback error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 427 return; 428 } 429 console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}'); 430 }); 431} catch (error) { 432 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 433} 434``` 435 436## requestPublishForm 437 438requestPublishForm(want: Want, callback: AsyncCallback<string>): void 439 440Requests to publish a widget to the widget host (usually the home screen). This API uses an asynchronous callback to return the result. 441 442**System capability**: SystemCapability.Ability.Form 443 444**System API**: This is a system API. 445 446**Parameters** 447 448| Name | Type | Mandatory| Description | 449| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ | 450| want | [Want](js-apis-app-ability-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' | 451| callback | AsyncCallback<string> | Yes | Callback used to return the widget ID.| 452 453**Error codes** 454 455| Error Code ID| Error Message| 456| -------- | -------- | 457| 202 | The application is not a system application. | 458| 401 | If the input parameter is not valid parameter. | 459| 16500050 | An IPC connection error happened. | 460| 16500100 | Failed to obtain the configuration information. | 461| 16501000 | An internal functional error occurred. | 462 463For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md). 464 465**Example** 466 467```ts 468import Want from '@ohos.app.ability.Want'; 469import Base from '@ohos.base'; 470 471let want: Want = { 472 abilityName: 'FormAbility', 473 parameters: { 474 'ohos.extra.param.key.form_dimension': 2, 475 'ohos.extra.param.key.form_name': 'widget', 476 'ohos.extra.param.key.module_name': 'entry' 477 } 478}; 479try { 480 formProvider.requestPublishForm(want, (error: Base.BusinessError, data: string) => { 481 if (error) { 482 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 483 return; 484 } 485 console.log(`formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}`); 486 }); 487} catch (error) { 488 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 489} 490``` 491 492## requestPublishForm 493 494requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData): Promise<string> 495 496Requests to publish a widget to the widget host (usually the home screen). This API uses a promise to return the result. 497 498**System capability**: SystemCapability.Ability.Form 499 500**System API**: This is a system API. 501 502**Parameters** 503 504| Name | Type | Mandatory| Description | 505| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 506| want | [Want](js-apis-app-ability-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' | 507| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. By default, no value is passed, indicating that no data is provided. | 508 509**Return value** 510 511| Type | Description | 512| :------------ | :---------------------------------- | 513| Promise<string> | Promise used to return the widget ID.| 514 515**Error codes** 516 517| Error Code ID| Error Message| 518| -------- | -------- | 519| 202 | The application is not a system application. | 520| 401 | If the input parameter is not valid parameter. | 521| 16500050 | An IPC connection error happened. | 522| 16500100 | Failed to obtain the configuration information. | 523| 16501000 | An internal functional error occurred. | 524 525For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md). 526 527**Example** 528 529```ts 530import Want from '@ohos.app.ability.Want'; 531import Base from '@ohos.base'; 532 533let want: Want = { 534 abilityName: 'FormAbility', 535 parameters: { 536 'ohos.extra.param.key.form_dimension': 2, 537 'ohos.extra.param.key.form_name': 'widget', 538 'ohos.extra.param.key.module_name': 'entry' 539 } 540}; 541try { 542 formProvider.requestPublishForm(want).then((data: string) => { 543 console.log(`formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}`); 544 }).catch((error: Base.BusinessError) => { 545 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 546 }); 547} catch (error) { 548 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 549} 550``` 551 552## isRequestPublishFormSupported 553 554isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void 555 556Checks whether a widget can be published to the widget host. This API uses an asynchronous callback to return the result. 557 558**System API**: This is a system API. 559 560**System capability**: SystemCapability.Ability.Form 561 562**Parameters** 563 564| Name| Type | Mandatory| Description | 565| ------ | ------ | ---- | ------- | 566| callback | AsyncCallback<boolean> | Yes| Callback used to return whether the widget can be published to the widget host.| 567 568**Error codes** 569 570| Error Code ID| Error Message| 571| -------- | -------- | 572| 202 | If the application is not a system application. | 573| 401 | If the input parameter is not valid parameter. | 574| 16500050 | An IPC connection error happened. | 575| 16501000 | An internal functional error occurred. | 576 577For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md). 578 579**Example** 580 581```ts 582import Want from '@ohos.app.ability.Want'; 583import Base from '@ohos.base'; 584 585try { 586 formProvider.isRequestPublishFormSupported((error: Base.BusinessError, isSupported: boolean) => { 587 if (error) { 588 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 589 } else { 590 if (isSupported) { 591 let want: Want = { 592 abilityName: 'FormAbility', 593 parameters: { 594 'ohos.extra.param.key.form_dimension': 2, 595 'ohos.extra.param.key.form_name': 'widget', 596 'ohos.extra.param.key.module_name': 'entry' 597 } 598 }; 599 try { 600 formProvider.requestPublishForm(want, (error: Base.BusinessError, data: string) => { 601 if (error) { 602 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 603 return; 604 } 605 console.log(`formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}`); 606 }); 607 } catch (error) { 608 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 609 } 610 } 611 } 612 }); 613} catch (error) { 614 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 615} 616``` 617 618## isRequestPublishFormSupported 619 620isRequestPublishFormSupported(): Promise<boolean> 621 622Checks whether a widget can be published to the widget host. This API uses a promise to return the result. 623 624**System API**: This is a system API. 625 626**System capability**: SystemCapability.Ability.Form 627 628**Return value** 629 630| Type | Description | 631| :------------ | :---------------------------------- | 632| Promise<boolean> | Promise used to return whether the widget can be published to the widget host.| 633 634**Error codes** 635 636| Error Code ID| Error Message| 637| -------- | -------- | 638| 202 | If the application is not a system application. | 639| 16500050 | An IPC connection error happened. | 640| 16501000 | An internal functional error occurred. | 641 642For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md). 643 644**Example** 645 646```ts 647import Want from '@ohos.app.ability.Want'; 648import Base from '@ohos.base'; 649 650try { 651 formProvider.isRequestPublishFormSupported().then((isSupported: boolean) => { 652 if (isSupported) { 653 let want: Want = { 654 abilityName: 'FormAbility', 655 parameters: { 656 'ohos.extra.param.key.form_dimension': 2, 657 'ohos.extra.param.key.form_name': 'widget', 658 'ohos.extra.param.key.module_name': 'entry' 659 } 660 }; 661 try { 662 formProvider.requestPublishForm(want).then((data: string) => { 663 console.log(`formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}`); 664 }).catch((error: Base.BusinessError) => { 665 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 666 }); 667 } catch (error) { 668 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 669 } 670 } 671 }).catch((error: Base.BusinessError) => { 672 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 673 }); 674} catch (error) { 675 console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`); 676} 677``` 678