Interacting with Lucy
props.uxpContext.executeService('User','GetEmail',{'user':'admin'})
.then(data => console.log(data))
.catch(e => console.error(e));const UserEmailWidget:React.FunctionComponent<IWidgetProps> = (props) => {
let [email,setEmail] = React.useState('');
async function getUserEmail(user:string) {
let result = await props.uxpContext.executeAction('User','GetEmail',{'userId':user },{json:true});
return result.email;
}
/* Get the email address the first time the page loads */
React.useEffect(()=>{
getUserEmail('admin').then(email => setEmail(email));
});
return <WidgetWrapper>
<div>
{email}
</div>
</WidgetWrapper>;
}
Last updated