Skip to content

Commit 92ec46c

Browse files
committed
fix: remove unused request dependency
1 parent 69fa6b8 commit 92ec46c

File tree

3 files changed

+112
-190
lines changed

3 files changed

+112
-190
lines changed

FETCH_MIGRATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Code will be on the `master` branch.
5656
- [x] migrate src/watch.ts and its tests to fetch api from request
5757
- [x] remove decprecated requestImpl and RequestInterface
5858
- [x] implement queryParams parameter in watch method by injecting them into the fetch call
59-
- [ ] update tests in src/watch_test.ts
59+
- [x] update tests in src/watch_test.ts
6060
- [ ] Fix errors in test (due to new api)
6161
- [ ] Test all features
6262
- [ ] Fix examples and validate their param signatures (due to new api)

src/watch.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,16 @@ export class Watch {
6868

6969
await fetch(watchURL, requestInit)
7070
.then((response) => {
71-
response.body.pipe(stream);
71+
if (response.status === 200) {
72+
response.body.on('error', doneCallOnce);
73+
response.body.pipe(stream);
74+
} else {
75+
const error = new Error(response.statusText) as Error & {
76+
statusCode: number | undefined;
77+
};
78+
error.statusCode = response.status;
79+
throw error;
80+
}
7281
})
7382
.catch(doneCallOnce);
7483

0 commit comments

Comments
 (0)