your recipe card header background

    Loader with Parameters

    0

    1

    Jose Romero

    Remix JavaScript public recipes

    Defines a loader function that fetch data from an API using the getDataById function.

    Library: remix

    Shortcut: remix.loader.params

    import { json, LoaderFunction } from "remix";
    import invariant from "tiny-invariant";
    
    export const loader = async ({ params }) => {
      invariant(params.id, "expecting an identifier");
      return json(await getDataById(id));
    };
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.