I have a type called Person like this :
type Person = {
value?: string[];
label?: string[];
};
I have this promise function
async function main(): Promise<Person> {
const foo = await dynamicsWebApi.retrieveAll("accounts",["name"]).then(function (stuff) {
var records = stuff.value
const options = records?.map(d => ({
"value" : d.name,
"label" : d.name
}))
console.log(options)
}).catch(function (error) {
console.log(error)
})
return options
}
So I transform the api call into value and label (it is called options) and I need to pass this to a react component (in my return statement.
but I am getting the error
Type 'string[]' has no properties in common with type 'Person'
when I hover over the 'return options' command .
Any idea how I can craft my promise better to avoid this error ?
Thanks !