()
| 11 | */ |
| 12 | export class Fetch extends Polling { |
| 13 | override doPoll() { |
| 14 | this._fetch() |
| 15 | .then((res) => { |
| 16 | if (!res.ok) { |
| 17 | return this.onError("fetch read error", res.status, res); |
| 18 | } |
| 19 | |
| 20 | res.text().then((data) => this.onData(data)); |
| 21 | }) |
| 22 | .catch((err) => { |
| 23 | this.onError("fetch read error", err); |
| 24 | }); |
| 25 | } |
| 26 | |
| 27 | override doWrite(data: string, callback: () => void) { |
| 28 | this._fetch(data) |