import { client } from "./stream";
export default async function handler(
) { try {
try {
- await client.upsertUser({
username: username as string,
id: user_id as string,
image: image as string,
});
} catch (error) {
console.error("Error upserting user:", error);
return res.status(500).json({ error: "Error upserting user" });
}
try {
const token = client.createToken(user_id as string);
return res.status(200).json({ token });
} catch (error) {
console.error("Error creating token:", error);
return res.status(500).json({ error: "Error creating token" });
}
} catch (error) {
console.error("Internal server error:", error);
return `res.status(500).json({ error: "Internal server error" });`
}
}`
I am trying to create a user in Stream Chat, and I have followed their documentation. However, when I attempt to create the user, this error is being thrown.