Skip to content

Commit

Permalink
Prevent consuming the body response twice
Browse files Browse the repository at this point in the history
  • Loading branch information
ybizeul committed Jan 9, 2024
1 parent 07a133b commit 7132f11
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions web/ui/src/YBFeed/YBFeedConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@ export class YBFeedConnector {
reject(new YBFeedError(f.status, text))
})
}
f.json()
.then(j => {
j.vapidpublickey = f.headers.get("Ybfeed-Vapidpublickey")
for (let i=0;i<j.items.length;i++) {
j.items[i].feed = j
}
resolve(j)
})
.catch((e) => {
reject(new YBFeedError(e.status, "Server Error"))
})
else {
f.json()
.then(j => {
j.vapidpublickey = f.headers.get("Ybfeed-Vapidpublickey")
for (let i=0;i<j.items.length;i++) {
j.items[i].feed = j
}
resolve(j)
})
.catch((e) => {
reject(new YBFeedError(e.status, "Server Error: " + e.message))
})
}
})
.catch((e) => {
reject(new YBFeedError(e.status, "Server Unavailable"))
Expand Down

0 comments on commit 7132f11

Please sign in to comment.