I am new to node and am trying to using A node.js library for the Pardot API
This I pass my userKey
, email
and password
to pardot, this returns my api_key
.
I am using the following code to authenticate, then when I run my node server I can see the api_key being passed back.
how do I then store that api_key as a variable to then use to post data to the API?
my node code
var nodePardot = require('node-pardot');
// Create client using email, password and user_key
nodePardot.PardotAPI({
userKey: 'kyujk',
email: 'uu.uuy@uu.co.uk',
password: 'uit.09',
DEBUG: true
}, function(err, client) {
// Authentication completed
console.log('Authentication completed');
// gets api key
var api_key = api_key;
console.log('key',api_key);
});
my console output
[nodemon] restarting due to changes...
[nodemon] starting `node index.js`
Server started! At http://localhost:8080
Initializing node-pardot in DEBUG mode
params {"email":"bhyuyten.jj@jyj.co.uk","password":"tyjt.09","user_key":"yjty76","format":"json"}
uri https://pi.pardot.com/api/login/version/3?email=ss.jyj%s.co.uk&password=tyjt.09&user_key=yjty76&api_key=&format=json
parsedResponse {"@attributes":{"stat":"ok","version":1},"api_key":"878074492492dhjjk67u","version":4}
Authentication completed
key undefined
parsedResponse {"@attributes":{"stat":"ok","version":1},"api_key":"878074492492dhjjk67u","version":4}
var nodePardot = require('node-pardot');
// Create client using email, password and user_key
nodePardot.PardotAPI({
userKey: 'fdgr',
email: 'rg.gg@gg.co.uk',
password: 'dfherg',
DEBUG: true
}, function(err, client) {
// Authentication completed
console.log('Authentication completed');
// gets api key
var api_key = api_key;
console.log('key',api_key);
});
via Beep
No comments:
Post a Comment