KeemROH
KeemROH

Reputation: 37

HOW TO POST DATA IN NODE.JS

So basically after looking at the api documentation for c0gnito.cc I tried setting up calling the api and trying to post data, I hope what I did makes enough sense but how would I post this data in Node.js?

"url": "api.c0gnito.cc/generate-keys",
"headers": {
 "privateKey": "privatekey",
 "numberOfLicenses": "1",
 "expiryTime": "24",
 "customMask": "HITLIST-xxxx-xxxx-xxxx"
}

EDIT: I do not understand how I can POST this data, i would appreciate an example, an example to post data as shown above.

Upvotes: 0

Views: 89

Answers (1)

jfriend00
jfriend00

Reputation: 707258

Using the got() library (instead of the deprecated request library) and using the headers you show, you could do something like this:

const got = require('got');

got.post("http://api.c0gnito.cc/generate-keys", {
    headers: {
        privateKey: "privatekey",
        numberOfLicenses: "1",
        expiryTime: "24",
        customMask: "HITLIST-xxxx-xxxx-xxxx"
    }
}).then(results => {
    console.log(results);
}).catch(err => {
    console.log(err);
});

Upvotes: 1

Related Questions