async await for default value
async await for default value
![aazwar](https://secure.gravatar.com/avatar/030d53b12d72ce4e0ca5f230b2ae0fbc/?default=https%3A%2F%2Fvanillicon.com%2F030d53b12d72ce4e0ca5f230b2ae0fbc_200.png&rating=g&size=120)
I've tried async await for default value, but it doesn't work
{ label: 'Number', name: 'number',
async def() {
let resp = await fetch('{{@BASE}}/ajax/reference/new-id?type=' + type);
return resp;
}
},
The corresponding input in the editor contains '[object Promise]'
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
The
field.def
option does not accept a promise in return. What you would need to do is useinitCreate
to trigger your Ajax request and then write tofield().val()
to set the field when it is complete.Allan