Code Monkey home page Code Monkey logo

typeform-client's Introduction

@lirantal/typeform-client

a friendlier Typeform Node.js API client

npm version license downloads build codecov known vulnerabilities semantic-release Security Responsible Disclosure

About

@lirantal/typeform-client provides a friendlier access to pulling form data out of Typeform through their API. The official Typeform API client provides only raw access to the API and it is upon the consumer of their SDK to stich all the data. Some of the benefits that this friendlier interface to interface provides are:

  • Looping through all the form survey results with the continuation token
  • De-normalizing all the data such as form questions, and their responses, so everything is accessible from an aggregated interface.

Install

npm install --save @lirantal/typeform-client

Example

const {Form} = require('@lirantal/typeform-client')

// don't hard-code API keys inside the code. Load it via configuration
// management or another secure form. For convenience only this library
// also supports falling back to reading the API key from a TYPEFORM_API_KEY
// environment variable.
// (note: SECRETS IN ENVIRONMENT VARIABLES ARE HIGHLY DISCOURAGED)
const apiKey = config.apiKey
// provide the form id for the typeform survey, which is present as part
// of a URL resource
const formId = config.formId

const typeform = new Form({apiKey: apiKey})
const form = await typeform.fetchFormResponses(formId)

// form is an object with all the form responses, and each question field is
// populated with all the answers collected from the survey

Supported fields

The following form fields are currently supported to extract:

  • Yes/No questions (yes_no)
  • Opinion scale questions (opinion_scale)
  • All variants of multiple choice questions, including an 'other' field, and single vs multiple answers (multiple_choice)
  • Free text questions (short_text)

Related

typeform-export-excel - Export a Typeform survey questionnaire to an Excel format

Contributing

Please consult CONTIRBUTING for guidelines on contributing to this project.

Author

typeform-export-excel © Liran Tal, Released under the Apache-2.0 License.

typeform-client's People

Contributors

arszh avatar lirantal avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

typeform-client's Issues

Add short_text types of answers

Is your feature request related to a problem? Please describe.
No.

Describe the solution you'd like
Add support for short_text like the “your name” or “your email” to also get included in all the results in the excel

Cannot read property "token" of undefined

Using the sample code in the readme to fetch a form, I'm getting:

(node:23596) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'token' of undefined
    at Form._fetchResponses (~/node_modules/@lirantal/typeform-client/src/Form/Form.js:95:31)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Form.fetchFormResponses ~/node_modules/@lirantal/typeform-client/src/Form/Form.js:118:51)
    at async ~/test.js:16:14

The error comes from this line in the node module:

      if (apiResult.page_count === 1) {
        break
      } else {
        const len = apiResult.items.length
        const lastItem = apiResult.items[len - 1]
        tokenValue = lastItem.token
      }

Might need a more defensive fix?

For reference, my form has 6 questions and no responses.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.