mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-12 17:22:03 -06:00
* only add packages once to their main package and remove them from other packages to avoid version conflicts * update package versions * update package versions, clean packages * remove old vscode settings * exclude formbricks-com from pnpm dev * narrow down tsconfig includes, pnpm-lock update * add pnpm test to github action
@formbricks/api - API Wrapper for Formbricks
Installation
npm install @formbricks/api
Usage
Create API Client
import { FormbricksAPI, EnvironmentId } from "@formbricks/api";
const api = new FormbricksAPI({
apiHost: "http://localhost:3000",
environmentId: "clgwh8maj0005n2f66pwzev3r" as EnvironmentId,
});
Note
All of the following methods return a
Resultfrom the@formbricks/errorspackage.
Create a new response
const response = await api.createResponse({
surveyId: "......" as SurveyId,
personId: "......" as PersonId,
data: {
questionId: "response",
},
});
Update an existing response
const response = await api.updateResponse({
responseId: "......" as ResponseId, // If you pass response.value.id from createResponse, you dont need 'as ResponseId'
data: {
questionId: "response",
},
});