Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taking data from a single json file #2

Open
nimit2801 opened this issue Jun 27, 2021 · 0 comments
Open

Taking data from a single json file #2

nimit2801 opened this issue Jun 27, 2021 · 0 comments

Comments

@nimit2801
Copy link

I was just exploring the project and wondered it would be better fetching from a single json file and single json file and fetched data from there.

export async function getServerSideProps({ params }) {
  const req = await fetch(`http://localhost:3000/cars.json`);
  const data = await req.json();
  const carData = data[params.id];
  return {
    props: { car: carData },
  };
}

Would be fun to use this.
Thoughts @codediodeio ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant