I try to do a simple login from Remix. I inspire myself from https://remix.run/docs/en/main/discussion/pending-ui.
I want to do a simple login system just to try without no database, but when I launch the script I have got the missing createRequest
.
import {
ActionFunction,
redirect,
ActionFunctionArgs
} from "@remix-run/node"
import { Form, useActionData, } from "@remix-run/react";
import {createRequest } from "run/node";
export async function action({ request, }: ActionFunctionArgs) {
const formData = await request.formData();
const project = await ccreateRequest({
username:formData.get("username"),
password: formData.get("password"),
});
if (project.username === "admin" && project.password === "password") {
// Redirect to the dashboard or home page after login
return redirect("/dashboard");
}
return {
errorMessage: "Invalid username or password",
};
}
Could you help me to find the dependance for createRequest
?
there's no such function createRequest
. The example code that you shared in the link uses createRecord
, which is some custom function you should be creating that processes the submitted data (could be inserting to database), in your case, you could just do:
import { ActionFunction, redirect,ActionFunctionArgs } from "@remix-run/node"
import { Form, useActionData, } from "@remix-run/react";
// import {createRequest } from "run/node"; //this does not exist
export async function action({request,}: ActionFunctionArgs) {
const formData = await request.formData();
// get username and password from formData
const username = formData.get("username");
const password = formData.get("password");
if (username === "admin" && password === "password") {
// Redirect to the dashboard or home page after login
return redirect("/dashboard");
}
return {
errorMessage: "Invalid username or password",
};
}