So if chatgpt cannot write my code, I’m SOL?
Can you think of any existing modules that can be edited (like weather) to get the desired result?
So if chatgpt cannot write my code, I’m SOL?
Can you think of any existing modules that can be edited (like weather) to get the desired result?
Extreme noob here so be gentle.
First, crice009 has created a module to pull NOAA tide data from a specific monitoring station and graph predicted vs actual data. I’m looking for something a little different. I’d like to see a simple chart consisting of the tide times and heights for three days pulled every night. Should I create a new module or fork off of crice009’s.
I am reading the MM module building documentation but a LOT is going over my head.
Reading some other posts, I got the idea to ask chatgpt to write the code I think I want. Tell me what you think.
const axios = require('axios');
const moment = require('moment');
// Function to fetch tide data for a specific date
async function fetchTideData(date) {
try {
const response = await axios.get('https://api.tidesandcurrents.noaa.gov/api/prod/datagetter', {
params: {
begin_date: date.format('YYYYMMDD'),
end_date: date.format('YYYYMMDD'),
station: '8722670', // NOAA station ID for Port of West Palm Beach
product: 'predictions',
datum: 'MLLW',
units: 'english',
time_zone: 'lst_ldt',
format: 'json',
}
});
return response.data.predictions;
} catch (error) {
console.error('Error fetching tide data:', error);
return [];
}
}
// Function to display tide data for a specific date
function displayTideData(date, tideData) {
console.log(`High and Low Tides for Port of West Palm Beach (Date: ${date.format('YYYY-MM-DD')})`);
console.log('--------------------------------------------------');
console.log('| Time | Type | Height (feet) |');
console.log('--------------------------------------------------');
tideData.forEach(tide => {
console.log(`| ${tide.t} | ${tide.type} | ${tide.v} |`);
});
console.log('--------------------------------------------------');
}
// Function to fetch and display tide data for today, tomorrow, and the following day
async function fetchAndDisplayTideData() {
const today = moment();
for (let i = 0; i < 3; i++) {
const date = today.clone().add(i, 'days');
const tideData = await fetchTideData(date);
displayTideData(date, tideData);
}
}
// Main function to execute the program
async function main() {
await fetchAndDisplayTideData();
}
// Run the main function
main();