2017-08-22 4 views
0

J'ai du mal à importer et à utiliser nano dans mon application de noeud.Comment importer nano (couchdb) - tapuscrit

La façon js (du doc) est:

var nano = require('nano')('http://localhost:5984'); 

Comment puis-je faire avec tapuscrit?

J'ai essayé

import * as Nano from "nano"; 
let nano = new Nano('http://localhost:5984'); 

Mais je reçois: Nano est pas un objet.

Répondre

2

En installant @ types/nano nous pouvons regarder:

node_modules/@types/nano/index.d.ts 

où l'on voit les lignes:

declare function nano(config: nano.Configuration | string): 
nano.ServerScope | nano.DocumentScope; 

Signification Nano est une fonction et non un objet, donc la réponse:

import * as Nano from "nano"; 
let nano = Nano('http://localhost:5984');