const formatData = ((els) => {
console.log("ELS : ", els.data); /* Got Undefined */
return _.each(els, (el) => ({
label: el.first_name,
value: el.id,
}));
});
const fetchOptions = ((input, callback) => {
return fetch("http://reqres.in/api/users")
.then((res) => {
callback(null,
{
options: formatData(res.json())
}
)
}).then((json) => {
return {options: json};
});
});
根据此文档,我正在尝试获取数据并将其设置为loadOptions
与<Select.Async ... />
. 正如我上面提到的,我得到Undefined
了 els.data。谁能告诉我我做错了什么?