How can i return this promise data in template with function and parameter data looping?
this was my code:
let data = [
{
id: 1,
model: "DIY-MULTI3-27HP230C"
}
]
const getByModelNo = async ({ id, params }: { id: string, params?: AxiosRequestConfig }) => {
const options = {
method: 'GET',
url: `${prefix}/${id}`,
params
};
let data: DataFromModel | any = {};
try {
const response = await axios.request(options);
data = response?.data?.data
} catch (error) {
console.error('Error fetching configurator-post:', error);
}
return data;
}
)
i want the result can return like this example:
return(
<div>
{data.map((items, index) => (
<div key={index}>{getByModelNo({id: items.model}).seriesName }</div>
)
)}
</div>