An API call made in getStaticProps seems to cause an error 500.
Here's my component's code:
import React from "react";
import API from "services/api";
const ArtistListPage = (props) => {
return (
<>
{props.artists.map((artist) => (
<div key={artist.id}>{artist.first_name}</div>
))}
</>
);
};
export async function getStaticProps() {
// Get external data from the file system, API, DB, etc.
const res = await API.get("/get_artists");
const artists = await res.data.json();
return {
props: { artists },
};
}
export default ArtistListPage;
I'd like to mention that the same API call in a useEffect works, as well as passing in a hard coded object to props in getStaticProps. Only the API call inside the getStaticProps seems to cause an issue.
Does anyone know where the error could come from and how to solve it?