Snippets Collections
<!DOCTYPE html>

<html>

​

<head>

    <style>

        <title>404 - Page Not Found</title><link rel="stylesheet"type="text/css"href="styles.css"/>CSS: body,

        html {

            height: 0%;

            margin: 0;
10
            padding: 0;

        }

​

        .container {

            display: flex;

            justify-content: center;

            align-items: center;

            height: 100%;

            background-color: rgba(0, 0, 0, 0.25);

        }

​

        img {

            max-width: 100%;
try {
  potentialFail();
} catch (error) {
  console.log(error);
}
  const getMovies = async (url) => {
    setError(null);
    try {
      const response = await fetch(url);

      if (!response.ok) {
        throw new Error("Something went wrong!");
      }

      const data = await response.json();
      
      if (data.results.length === 0) {
        throw new Error("Sorry, no movies were found.");
      }
      
      const transformedMovies = data.results.map((movie) => {
        return {
          id: movie.id,
          title: movie.title,
          description: movie.overview,
          rating: movie.vote_average,
          genres: movie.genre_ids,
          poster_path: movie.poster_path,
          backdrop_path: movie.backdrop_path,
          year: movie.release_date
        }
      })
      setTotalPages(data.total_pages);
      setMovies(transformedMovies);
      chooseMovie(transformedMovies);
    } catch (errorThrown) {
      setError(errorThrown.message);
    }
  }
star

Wed May 24 2023 19:01:55 GMT+0000 (Coordinated Universal Time) https://github.com/LingoBotics/LingoBotics.github.io/404.html

#html #css #404 #error #redirect
star

Wed Apr 05 2023 22:23:14 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-try-catch-in-javascript/

#javascript #try #error #catch
star

Mon May 24 2021 17:37:55 GMT+0000 (Coordinated Universal Time)

#react #api #fetch #async #error

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension