Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb9f187b

Browse files
somereticalYankai ZhuDomin0de
authored
I2 17/events api hotfix (#61)
* Added backend events API* polished code* Fix to read fetched events data correctly* Update eventInfo properly* Update event fetching error handling* fix type error* fix event concat---------Co-authored-by: Yankai Zhu <z5482795@ad.unsw.edu.au>Co-authored-by: Domin0de <31204305+Domin0de@users.noreply.github.com>
1 parent49600e0 commitb9f187b

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

‎backend/src/data/eventData.ts‎

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ export async function fetchEvents() {
5959
`https://graph.facebook.com/${FB_API_VERSION}/${process.env.FB_EVENT_PAGE_ID}/events?access_token=${process.env.FB_ACCESS_TOKEN}&fields=id,name,cover,place,start_time,end_time`
6060
);
6161

62-
if(!response||response.type===ResultType.Err){
63-
console.log(`No events found...\n${response}`);
64-
return[];
62+
if(!response.ok){
63+
thrownewError(JSON.stringify(response.json()));
64+
6565
}
6666
constres:FacebookEventsResponse=awaitresponse.json();
6767

@@ -85,22 +85,17 @@ export async function fetchEvent(id: string) {
8585
`https://graph.facebook.com/${FB_API_VERSION}/${id}?access_token=${process.env.FB_ACCESS_TOKEN}&fields=id,name,cover,place,start_time,end_time`
8686
);
8787

88-
constres:Result<FacebookEvent,FacebookError>=awaitresponse.json();
89-
90-
if(!res||res.type===ResultType.Err){
91-
thrownewError(
92-
`Couldn't fetch details for event${id}\n${inspect(
93-
Object.getOwnPropertyDescriptor(res,"error")?.value
94-
)}`
95-
);
88+
if(!response.ok){
89+
thrownewError(`Couldn't fetch details for event${id}\n${JSON.stringify(response.json())}`);
9690
}
91+
constres:FacebookEvent=awaitresponse.json();
9792

9893
returnnewEventInfo(
99-
res.value.id,
100-
res.value.name,
101-
res.value.start_time,
102-
res.value.end_time,
103-
res.value.place?.name??DEFAULT_EVENT_LOCATION,
104-
res.value.cover?.source??DEFAULT_EVENT_IMAGE
94+
res.id,
95+
res.name,
96+
res.start_time,
97+
res.end_time,
98+
res.place?.name??DEFAULT_EVENT_LOCATION,
99+
res.cover?.source??DEFAULT_EVENT_IMAGE
105100
);
106101
}

‎backend/src/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dotenv.config();
1111
(async()=>{
1212
try{
1313
constevents=awaitfetchEvents();
14-
eventInfoMutex.runExclusive(()=>eventInfo.concat(events));
14+
eventInfoMutex.runExclusive(()=>eventInfo.push(...events));
1515
console.log("Events fetched successfully");
1616
}catch(error){
1717
// do we ungracefully bail out here???

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp