mirror of
https://github.com/clarencechaan/ufc-cal.git
synced 2026-10-19 08:38:30 -07:00
Implement fetchEvent function in api.js
This commit is contained in:
1 parent
0b89eadd55
commit
0abdf42280
1 file changed
+20
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Returns the details of a UFC event given its event ID and using the UFC API
|
||||||
|
*
|
||||||
|
* @param {number} eventId - The ID of a UFC event
|
||||||
|
* @returns {Promise<object>} - A Promise that resolves with the details of
|
||||||
|
* a UFC event
|
||||||
|
*/
|
||||||
|
async function fetchEvent(eventId) {
|
||||||
|
try {
|
||||||
|
const url =
|
||||||
|
"https://d29dxerjsp82wz.cloudfront.net/api/v3/event/live/" +
|
||||||
|
eventId +
|
||||||
|
".json";
|
||||||
|
const response = await fetch(url);
|
||||||
|
const event = await response.json();
|
||||||
|
return event;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user