Files
formbricks-formbricks/packages/lib/client/display.ts
T
Matti Nannt 97263a66cc Add new client endpoints & webhook functionality (#355)
* add new zod schema for responses
* add new client endpoints for responses
* add services for responses and surveys
* add new responses model to webhooks & email

---------

Co-authored-by: Johannes <johannes@formbricks.com>
2023-06-12 19:51:13 +02:00

37 lines
1000 B
TypeScript

import { DisplayCreateRequest } from "@formbricks/types/js";
export const createDisplay = async (
displayCreateRequest: DisplayCreateRequest,
apiHost: string,
environmentId: string
): Promise<{ id: string }> => {
const res = await fetch(`${apiHost}/api/v1/client/environments/${environmentId}/displays`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(displayCreateRequest),
});
if (!res.ok) {
console.error(res.text);
throw new Error("Could not create display");
}
return await res.json();
};
export const markDisplayResponded = async (
displayId: string,
apiHost: string,
environmentId: string
): Promise<void> => {
const res = await fetch(
`${apiHost}/api/v1/client/environments/${environmentId}/displays/${displayId}/responded`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
}
);
if (!res.ok) {
throw new Error("Could not update display");
}
return;
};