Grab database info from client component
Unanswered
Munchkin posted this in #help-forum
MunchkinOP
I am trying to use appwrite to get my Database but everytime i try to grab it from my "use server" script i get the message TypeError: e._formData.
I am not using any forms and i am not even trying to reach a server at points.
Therefore i would like to start from scratch but i would like some help.
Using UseEffect i want to call an async function from a "use server" script that for now just returns me a simple string.
Any help is appreciated (IMPORTANT: using javascript. not typescript)
I am not using any forms and i am not even trying to reach a server at points.
Therefore i would like to start from scratch but i would like some help.
Using UseEffect i want to call an async function from a "use server" script that for now just returns me a simple string.
Any help is appreciated (IMPORTANT: using javascript. not typescript)
18 Replies
MunchkinOP
Fire ant
are u using "use server" from client or server component?
MunchkinOP
server component.
I am forcing my client component to be a client because i want to be able to use useState.
I am forcing my client component to be a client because i want to be able to use useState.
So i have 2 scripts basicly: one to handle the DB call and returns me the array of data.
and i want to pass that data to my Client script.
and i want to pass that data to my Client script.
Fire ant
Check the docs on grabbing data from server actions https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations
@Fire ant Check the docs on grabbing data from server actions https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations
MunchkinOP
I did. I have been working on this for days and i keeps returning me this error:
and
Error: e._formData.get is not a function//LoadDatabase.jsx
"use client"
import { useEffect, useState } from "react";
import { GetBasicReply } from "./Database";
export default function GrabSpells(){
const [Data,setData] = useState();
useEffect(()=>{
const Getspells = async () => {
const x = await GetBasicReply();
setData(x);
};
Getspells();
},[])
console.log(Data);
}and
//Database.jsx
"use server"
export async function GetBasicReply(){
try{
return "hello";
}
catch(e){
throw new Error("Failed to do anything");
}
}MunchkinOP
No, though i have singled out that this is not appwrite that is causing this
just converted previous repo to js
MunchkinOP
I finally found the difference You are using a form. that might be why it does work for you. I read though you can get the same effect if you use UseEffect but for me to avail.
so I have no idea why you get that error
MunchkinOP
Yeah i get the same error when i go to characterpage... Hmmm. could it maybe a mis-install from next or node?
might i ask which versions you use?
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:55:06 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6020
Binaries:
Node: 20.10.0
npm: 10.2.3
Yarn: N/A
pnpm: 8.14.1
Relevant Packages:
next: 14.0.4
eslint-config-next: 14.0.4
react: 18.2.0
react-dom: 18.2.0
typescript: 5.3.3
Next.js Config:
output: N/AMunchkinOP
yeah im lost at this point..
@Munchkin yeah im lost at this point..
create an issue with a minimal reproduction on github
MunchkinOP
will do.