Answers for "fetch error type"

19

fetch api javascript

fetch('http://example.com/movies.json')
  .then((response) => {
    return response.json();
  })
  .then((myJson) => {
    console.log(myJson);
  });
Posted by: Guest on February-10-2020
1

fetch error handling js

export async function getStaticProps(context) {
  const res = await fetch(`https://...`)
  const data = await res.json()

  //use this statement for the program not to crush but go back to the home page
  if (!data) {
    return {
      redirect: {
        destination: '/',
        permanent: false,
      },
    }
  }

  return {
    props: {}, // will be passed to the page component as props
  }
}
Posted by: Guest on December-08-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language