Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

Commit

Permalink
feat: Send status(alive) to WEB API
Browse files Browse the repository at this point in the history
  • Loading branch information
WayneChang65 committed Aug 6, 2020
1 parent 595aa52 commit 82c8152
Show file tree
Hide file tree
Showing 3 changed files with 340 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/to_webapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let request = require('request');
let apiUri = process.env.POKE_DC_RESTFUL_URI;

function _sendInfoToWebAPI() {
let url = apiUri + '/pokedc/status';
let url = 'http://' + apiUri + '/pokedc/status';
let options = {
'method': 'POST',
'url': url,
Expand All @@ -16,15 +16,20 @@ function _sendInfoToWebAPI() {
};

request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
if (error) {
//throw new Error(error);
process.stdout.write('?');
} else {
//console.log(response.body);
process.stdout.write('^');
}
});
}

function _run() {
setInterval(() => {
_sendInfoToWebAPI();
}, 1000);
}, 10 * 1000); // 10 sec
}

////////////// Module Exports //////////////////
Expand Down
Loading

0 comments on commit 82c8152

Please sign in to comment.