I am using the Async - React Select drop down in react - https://react-select.com/async The dataset for the drop down needs to look like this :
async function getPromise4(): Promise<Person[]> {
return [
{
value: 'Tom',
label: 'Tom',
},
{
value: 'David',
label: 'David',
},
{
value: 'MeeMee',
label: 'MeeMee',
},
];
}
and I am trying to get this created from an API. The API works ok but it doesn't give it back as value / label - so I cannot return the data direct to the drop down by a promise.
I am struggling to create an object like about. This is the code I use to get the data from the API.
async function main(): Promise<void> {
const foo = await dynamicsWebApi.retrieveAll("accounts",["name"]).then(function (stuff) {
var records = stuff.value
records.forEach(function (value) {
console.log(value.name);
This above code gets the data from the API fine. I guess I need to iterate over the data and build an object like above. I am sure its quite reasonable to do but I cannot seem to figure it out.