diff --git a/pages/index.js b/pages/index.js index bdd05c3..7ff5afc 100644 --- a/pages/index.js +++ b/pages/index.js @@ -7,17 +7,20 @@ import { toast } from "react-toastify" const Page = () => { const [mail, setMail] = useState() const handle = async () => { - const data = await fetch("https://api.picass.co/v1/early/mail", { + if(!mail) return toast.error("Please enter the email",{ + className: "toast-error toast", + }) + const data = await fetch("http://localhost:3001/v1/early/mail", { method: "POST", - body: { mail }, + body: new URLSearchParams({mail}), }) - const { message } = await data.json() if (data.status > 199 && data.status < 299) { toast.success(`Successfully ${mail} Joined`, { className: "toast toast-success", }) - } else { - toast.error(message, { + }else { + const { message } = await data.json() + toast.error(message,{ className: "toast-error toast", }) } @@ -30,13 +33,15 @@ const Page = () => {

All of your things, in one place

- setMail(e.target.value)} - value={mail} - > -