Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var session
- var credentials
- var resp
- function encodeBasicAuthorizationCredentials(options = {}) {
- return 'Basic ' + btoa(options.username + ":" + options.password)
- }
- function setCredentials(options = {}) {
- credentials = encodeBasicAuthorizationCredentials(options)
- }
- function getSession() {
- fetch("/api/session", { method: 'GET', headers: { 'Authorization': credentials } })
- .then(function(response) {
- response.json().then(function(json) { session = json })
- });
- }
- function setSession(data) {
- var request = new Request("/api/session", {
- method: 'POST',
- body: JSON.stringify(data),
- headers: {
- 'Authorization': credentials
- }
- });
- fetch(request).then(function(response) {
- response.json().then(function(json) { resp = json })
- });
- }
- setCredentials({ username: "bcap", password: "bcap" })
- data = {"cmd":"net.probe on"}
- setSession(data)
Add Comment
Please, Sign In to add comment