1# UIServiceHostProxy (System API) 2 3UIServiceHostProxy functions as a proxy to send data from the [UIServiceExtensionAbility](js-apis-app-ability-uiServiceExtensionAbility-sys.md) server to the client. 4 5 6> **NOTE** 7> 8> - The initial APIs of this module are supported since API version 14. Newly added APIs will be marked with a superscript to indicate their earliest API version. 9> - The APIs of this module can be used only in the stage model. 10> - The APIs of this module must be used in the main thread, but not in child threads such as Worker and TaskPool. 11> - The APIs provided by this module are system APIs. 12 13## Modules to Import 14 15```ts 16import { common } from '@kit.AbilityKit'; 17``` 18 19## UIServiceHostProxy 20 21### sendData 22 23sendData(data: Record\<string, Object>): void 24 25Sends data from the [UIServiceExtensionAbility](js-apis-app-ability-uiServiceExtensionAbility-sys.md) server to the client. 26 27**System capability**: SystemCapability.Ability.AbilityRuntime.Core 28 29**System API**: This is a system API. 30 31**Parameters** 32 33| Name| Type| Mandatory| Description| 34| -------- | -------- | -------- | -------- | 35| data | Record\<string, Object> | Yes| Data to be sent to the [UIServiceExtensionAbility](js-apis-app-ability-uiServiceExtensionAbility-sys.md) client.| 36 37**Error codes** 38 39For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md). 40 41| ID| Error Message| 42| ------- | -------------------------------- | 43| 202 | Not System App. Interface caller is not a system app . | 44| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 45| 16000050 | Internal error. | 46 47**Example** 48 49```ts 50import { common, UIServiceExtensionAbility } from '@kit.AbilityKit'; 51import { BusinessError } from '@kit.BasicServicesKit'; 52 53const TAG: string = '[UiServiceExtensionAbility] '; 54 55export default class MyUiServiceExtensionAbility extends UIServiceExtensionAbility { 56 // Process data sending. 57 onData(proxy: common.UIServiceHostProxy, data: Record<string, Object>) { 58 console.info(TAG + `onData ${JSON.stringify(data)}`); 59 // Define the data to be sent. 60 let formData: Record<string, string> = { 61 'proxyData': 'proxyData' 62 }; 63 try { 64 // Send data to the UIServiceExtensionAbility server. 65 proxy.sendData(formData); 66 } catch (err) { 67 let code = (err as BusinessError).code; 68 let msg = (err as BusinessError).message; 69 console.error(`${TAG} sendData failed, err code: ${code}, err msg: ${msg}.`); 70 } 71 } 72} 73``` 74