Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var timerName = 'Timer';
- var timerSeconds = 15;
- var username = 'ChrisMissal';
- var callback = function (response) { // if used for JSON-P
- var meta = response.meta;
- var data = response.data;
- console.log(meta);
- console.log(data);
- };
- var getNotifications = function () {
- device.ajax(
- {
- url: '',
- type: 'GET',
- headers: {
- 'Content-Type': 'application/json'
- }
- },
- function onSuccess(body, textStatus, response) {
- var data;
- if(!(body && (data = JSON.parse(body)))) {
- console.error('error: ', body || '(null)');
- }
- console.info(JSON.stringify(data));
- },
- function onError(textStatus, response){
- console.error('error code: ', response.status);
- });
- };
- device.scheduler.setTimer({
- name: timerName,
- time: 0,
- interval: timerSeconds*1000,
- exact: false },
- getNotifications);
- device.screen.on('off', function () {
- device.scheduler.removeTimer(timerName);
- });
Add Comment
Please, Sign In to add comment