Server: `import { Client, Account } from 'node-appwrite';
export default async function (req, res, log, error) { try {
const userClient = new Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('xxx') // Your project ID
.set(req.headers.authorization); // The user session to authenticate with
const account = new Account(userClient);
const result = await account.get();
res.status(200).json({ success: true });
} catch (err) { res.status(400).json({ success: false, error: e.message }); } }`
Client: ` const session = await account.getSession('current'); const jwt = await account.createJWT();
const response = await functions.createExecution(
'', // Function ID
'', // Body (optional)
false, // Async (optional)
undefined, // Path (optional)
ExecutionMethod.GET, // HTTP method (optional)
{ 'Authorization': `Bearer ${jwt.jwt}` }, // Headers (optional)
undefined
);`
Error: TypeError: Cannot read properties of undefined (reading 'status')
I want to retrieve the server-side information of a user who has logged in from the client and return it, but I'm having trouble doing so.
FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting).
Where did you get the Client()[…].set() syntax from?
The error seems to be on your res.status(…)
(i.e., .status() not being a valid method of res)
I need some more help with this. I checked if the res object is being passed correctly, but I'm still getting the same error. Could you help me with this?
You’ve confirmed that res.status() is a valid method? How did you do that?
Recommended threads
- Not allowed permission to upsert a prese...
```js const presenceID = ID.unique(); setPID(presenceID); const presence = await presences.upsert({ presenceId: presenceID, status: "online"...
- Finding job
Hi. I am a full-stack developer with experience in developing scalable and user-friendly web applications. I handle both front-end and back-end development, im...
- CDN not delivering correct bundle
My site 69b4cd410035893573dc is not delivering the latest deployed version via CDN, it seems stuck on versions from previoiu days, alternative links for the lat...