1

we usually use below statement to use authy library in node file using js ,mostly by require statement !

const authy = require('authy')('API KEY');

I've moved my code to nest eco system and now How should i do the same using typescript ,as i also want to pass API Key to it ? I've tried below code as well ,but still it's not working

import { authy } from 'authy'(API KEY)

suggest something !

Aniket
  • 127
  • 1
  • 11

1 Answers1

2

I have faced a similar issue in my NestJS project when using twillio library.

Currently, I have resolved this by importing it this way:

import authy = require('authy');

If, this doesn't work for you (for any reason e.g. TypeScript compile error), then can you try the following import statement?

import * as Authy from 'authy';

Also, let me know which one works for you.

Ayush Somani
  • 731
  • 7
  • 9
  • and how to pass API key to it ? – Aniket Sep 02 '21 at 04:41
  • @Aniket Can you try calling authy('API_KEY') OR Authy('API_KEY') to get the authy instance? If this doesn't work, then can you try like this: const authyInstance = authy.default('API_KEY'); Please let me know how it goes. – Ayush Somani Sep 02 '21 at 09:01