Open paulhwangfti opened 4 months ago
Here's my exact app.js
if needed
var express = require('express');
var SouthernCompanyAPI = require('southern-company-api').SouthernCompanyAPI;
var app = express();
app.get('/', function (req, res) {
res.send('Hello World!');
});
const username = 'omit';
const password = 'omit';
var monthlyDataJson = "failed";
const getUsage = async () => {
console.log('Getting Usage...');
console.log('Username: ' + username);
console.log('Password: ' + password);
/* Instantiating API */
const SouthernCompany = new SouthernCompanyAPI({
username: username,
password: password,
});
/* Listening for login success */
SouthernCompany.on('connected', ()=>{
console.info('Connected...');
async function fetchMonthly() {
/* Getting Monthly Data */
const monthlyData = await SouthernCompany.getMonthlyData();
/* Printing Monthly Data */
console.info('Monthly Data', JSON.stringify(monthlyData));
}
fetchMonthly();
async function fetchDaily() {
/* Getting Daily Data */
const startDate = new Date(2020, 2, 1);
const endDate = new Date();
const dailyData = await SouthernCompany.getDailyData(startDate, endDate);
/* Printing daily data */
console.info('Daily Data', JSON.stringify(dailyData));
}
fetchDaily();
});
/* Listening for any errors */
SouthernCompany.on('error', console.error);
}
getUsage().then(() => {
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
console.log(monthlyDataJson);
});
});
I haven't pushed a new version to npm yet but if you can pull the latest from this repo and try now.
If not, I should have a new version on npm in a day or so
3.1.0 has been published
I created a small node application to try and acquire some monthly usage data and was met with the following error.
The API doesn't seem to be working (at least for GA Power) and I essentially did a copy-paste of how the API should be used as shown in the
Readme.md