Whenever I try to make an axios get
request within a next.js getServerSideProps
function, I encounter a persistent TypeScript error underline on the map method. Despite troubleshooting extensively, I have not been able to resolve it. The request successfully retrieves data, but I am keen on eliminating the error. Any ideas on how to tackle this issue?
export const getServerSideProps: GetServerSideProps = async () => {
const { data } = await api.get("/users/index", { //axios api
params: {
_limit: 12
_sort: "created_at",
_order: "desc"
}
})
const users = data.map(user => { // <-error line under map method
return {
id: user.id,
name: user.name,
created_at: user.created_at,
}
});