-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using getSchedule() function will get problem #19
Comments
To resolve the issue, you should use either the
const MLBStatsAPI = require('mlb-stats-api');
const mlbStats = new MLBStatsAPI();
async function data() {
const response = await mlbStats.getSchedule({ params: { sportId: <your_sportId_here> }});
const data = await response.json();
return data;
}
async function main() {
try {
const scores = await data();
console.log(scores);
} catch (error) {
console.error(error + "error");
}
}
main(); Use 1 as
const MLBStatsAPI = require('mlb-stats-api');
const mlbStats = new MLBStatsAPI();
async function data() {
const response = await mlbStats.getSchedule({ params: { gamePk: <your_gamePk_here> }});
const data = await response.json();
return data;
}
async function main() {
try {
const scores = await data();
console.log(scores);
} catch (error) {
console.error(error + "error");
}
}
main(); The Please note that you need to replace |
I change my code to the below const MLBStatsAPI = require('./mlb-stats-api');
const mlbStats = new MLBStatsAPI();
async function data() {
const response = await mlbStats.getSchedule({ params: { sportId: 1 }});
const data = await response.json();
return data;
}
async function main() {
try {
const scores = await data();
console.log(scores);
} catch (error) {
console.error(error + "error");
}
}
main(); |
There is a flaw in some of the functions in how they extract the params to add them to the URL, some of the functions do work, but the construction of the URL's is not consistent. I forked the repo and I'm in the process of cleaning up the functions to use the URL object and the searchParams property to dynamically construct the querystring passed to the fetch call. |
My code:
'''
const MLBStatsAPI = require('mlb-stats-api');
const mlbStats = new MLBStatsAPI();
async function data() {
const response = await mlbStats.getSchedule({});
const data = await response.json();
return data;
}
async function main() {
try {
const scores = await data();
console.log(scores);
} catch (error) {
console.error(error + "error");
}
}
main();
'''
will get the result below:
{
messageNumber: 7,
message: 'Missing required parameter sportId or gamePk',
timestamp: '2023-05-04T08:02:25.845395735Z',
traceId: null
}
The text was updated successfully, but these errors were encountered: