Last active
October 17, 2018 10:57
-
-
Save ten2net/3a5a836dd76692a1c380a41c6ebc7006 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var host = 'localhost:8080'; | |
var username = 'tenant@thingsboard.org'; | |
var password = 'tenant'; | |
var user = { | |
'username': username, | |
'password': password | |
}; | |
var options = { | |
method: 'post', | |
url: 'http://' + host + '/api/auth/login', | |
headers: { | |
'Content-Type': 'application/json', | |
'Accept': 'application/json', | |
}, | |
body: JSON.stringify(user), | |
}; | |
request(options, function(error, response, body) { | |
console.log('error:', error); | |
console.log('statusCode:', response && response.statusCode); | |
console.log('body:', body); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go to directory of your project
mkdir TestProject cd TestProject
Make this directory a root of your project (this will create a default package.json file)
Install required npm module and save it as a project dependency (it will appear in package.json)
Create a test.js file in project directory with code from package example
Your project directory should look like this
Now just run node inside your project directory