Kong / Kong/httpsnippet

Unable to initialize library

Offen
#307 2 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
1.2k
Forks
242
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

The library is not getting instantiated, Created a basic node project and trying to instantiate the library. Does not work.

index.js
```js
const HTTPSnippet = require('httpsnippet').HTTPSnippet

const snippet = new HTTPSnippet({
method: 'GET',
url: 'http://mockbin.com/request',
});

const options = { indent: '\t' };
const output = snippet.convert('shell', 'curl', options);
console.log(output);
```

Package JSON
```json
{
"name": "http-code-generator",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"httpsnippet": "^2.0.0"
}
}
```

Getting this below error
```
const snippet = new HTTPSnippet({
^

TypeError: HTTPSnippet is not a constructor
at Object. (/Users/cpandit/WebstormProjects/untitled1/index.js:6:17)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
➜ untitled1

```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

The reproduction is in index.js, with the dependency pinned in package.json to httpsnippet ^2.0.0. Start by running node index.js and checking the value exported by the package; done means the shown HTTPSnippet initialization succeeds and produces the requested curl output.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, nodejs
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.