So I'm trying to get a MagicMirror module to get data from ComEd's API, compare it to the previous reading, and overwrite the previous reading with the current reading. I'm trying to use import/export, but it doesn't work.
'use strict';
Module.register("MMM-ComEdPrice", {
import 'previousPrice' from "~/MagicMirror/modules/MMM-ComEdPrice/previousPrice.js";
var lastPrice = previousPrice;
result: [],
// Default module config.
defaults: {
url: 'https://hourlypricing.comed.com/api?type=currenthouraverage',
fadeSpeed: 2000,
updateInterval: 5 * 60 * 1000, // every 5 minutes
},
At the beginning of the file, and
},
export { currentPrice };
});
At the end of it. The second file consists of the following:
import { currentPrice } from "modified_MMM-ComEdPrice.js";
var previousPrice=currentPrice;
export { previousPrice };
Update: Have also tried using fs, but it appears that I'm not using it correctly, as every line that I have put it throws an error.