Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/api/pet-snapshots-api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const superagent = require('superagent');
// Pull the common host/api into own module or env variable
const url = 'https://pawsio.herokuapp.com/api/pet-snapshots';

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/pets-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
getAll(token) {
return superagent.get(`${url}/all`)
.set('authorization', `Bearer ${token}`)
.then(res => res.body)
.then(res => res.body) // what happen to semicolons???
},
getOne(token, id) {
return superagent.get(`${url}/${id}`)
Expand Down
2 changes: 2 additions & 0 deletions lib/get-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const thermometer = require('./thermometer')();
const accelerometer = require('./accelerometer')();
const microphone = require('./microphone')();

// I don't think I would have used the factory function pattern for
// the modules in this project. Just seems like extra work.
module.exports = function getData() {
return function getData() {
return Promise.all([
Expand Down
8 changes: 4 additions & 4 deletions lib/lcd.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module.exports = function initiateLCD() {
// myLcd.write('Hello from PawsIO!');

return function displayMessage(x, y, message) {
// TODO: study repo on way to make the message loop across the screen
myLcd.setCursor(x, y);
myLcd.write(message);
};
// TODO: study repo on way to make the message loop across the screen
myLcd.setCursor(x, y);
myLcd.write(message);
};
};
4 changes: 3 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ function main() {
// if rotary is negative but have payload, check later whether we push
let rotarCurr = rotary();
console.log(rotarCurr);

// split the logic into functions and make the conditional workflow obvious
if(rotarCurr < 0) {
// if you have data to send, send it and then empty array
if(dataPayload.length && !uploading) {
Expand All @@ -58,7 +60,7 @@ function main() {
throw { message: 'no internet connection' };
};
})
.then(res => {
.then(() => {
dataPayload = [];
uploading = false;
lcd(1,0,'upload success');
Expand Down