@sentiment/api
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@sentiment/api - API Wrapper for Sentiment

Installation

npm install @sentiment/api

Usage

Create API Client
import { SentimentAPI, EnvironmentId } from "@sentiment/api";

const api = new SentimentAPI({
  apiHost: "http://localhost:3000",
  environmentId: "clgwh8maj0005n2f66pwzev3r" as EnvironmentId,
});

Note All of the following methods return a Result from the @sentiment/errors package.

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",
  },
});

Package Sidebar

Install

npm i @sentiment/api

Weekly Downloads

14

Version

1.0.0

License

MIT

Unpacked Size

75 kB

Total Files

11

Last publish

Collaborators

  • crawfordleeds