Back

[SOLVED]

  • 0
  • Functions
  • REST API
  • Cloud
Mosh Ontong
17 Jan, 2024, 23:28

I run my function through domain and console but still received this kind of error

My function code:

TypeScript
// This is your Appwrite function
// It's executed each time we get a request
export default async ({ req, res, log, error }: any) => {
  // Why not try the Appwrite SDK?
  const headers = req.headers;
  log(JSON.stringify(headers));
  // const client = new Client()
  //   .setEndpoint("https://cloud.appwrite.io/v1")
  //   .setProject(Bun.env["APPWRITE_FUNCTION_PROJECT_ID"])
  //   .setKey(headers["DDC_SECRET_KEY"]);

  // const databases = new Databases(client);

  // // The `req` object contains the request data
  // if (req.method === "GET") {
  //   const response = await databases.getDocument(
  //     "65a389d70bee25715a29",
  //     "65a85181f26b3b9f9232",
  //     headers["taramed-patient-id"]
  //   );

  //   return res.json({
  //     patientInfo: {
  //       firstName: response["firstName"],
  //       lastName: response["lastName"],
  //       dateOfBirth: response["dateOfBirth"],
  //       gender: response["gender"],
  //       address: response["address"],
  //       weight: response["weight"],
  //       weightUnit: response["weightUnit"],
  //     },
  //     vitalSigns: {
  //       heartRate: response["heartRate"],
  //       bloodPressure: response["bloodPressure"],
  //       respiratoryRate: response["respiratoryRate"],
  //       temperature: response["bodyTemperature"],
  //     },
  //   });
  // }

  // `res.json()` is a handy helper for sending JSON
  return res.json({
    motto: "Build like a team of hundreds_",
    learn: "https://appwrite.io/docs",
    connect: "https://appwrite.io/discord",
    getInspired: "https://builtwith.appwrite.io",
  });
};
TL;DR
The developer received an error when running their function through a domain and console. They shared their function code which includes commented out sections. They were trying to use the Appwrite SDK and make a GET request to retrieve data from a database, but the code is currently commented out. In the end, they are returning a JSON response with some key-value pairs. There is no solution mentioned in the thread.
Mosh Ontong
17 Jan, 2024, 23:32

[SOLVED]

ideclon
18 Jan, 2024, 00:44

What happened?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more