I have a form with a submit. When it is clicked I create an object to send these data to POST.
So I have saveEntity const:
const saveEntity = (event, errors, values) => { // this is the const that is signed as error: const valoreComune: any = comCod ? { comCod: { comCod: comCod } } : personEntity.comCod ? { comCod: { comCod: personEntity.comCod.comCod } } : { comCod: null }; //.... const entity = { // this is the object that I pass to post // .... valoreComune } }
I need to recreate this object structure:
comCod: { comCod: value }
or
comCod: null
Now I receive this error:
Expected property shorthand object-shorthand
Now usually i resolve writing directly in this way:
const entity = { valoreComune }
but it doesn’t work. How can I do?
Advertisement
Answer
You should use the object-shorthand syntax for this part:
{ comCod: { comCod: comCod } }
Which is written like so:
{ comCod: { comCod } }