https://github.com/elycheikhsmail/fetch_as_class
fetch data using class based on deno/browser fetch api
https://github.com/elycheikhsmail/fetch_as_class
class deno fetch poo
Last synced: about 1 month ago
JSON representation
fetch data using class based on deno/browser fetch api
- Host: GitHub
- URL: https://github.com/elycheikhsmail/fetch_as_class
- Owner: elycheikhsmail
- Created: 2022-01-17T00:28:55.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-17T14:01:51.000Z (over 4 years ago)
- Last Synced: 2026-03-06T19:51:50.132Z (4 months ago)
- Topics: class, deno, fetch, poo
- Language: TypeScript
- Homepage: https://github.com/elycheikhsmail/fetch_as_class
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fetch_as_class
class for fetch data based on fetch api
example
```
//sava as my.test.ts
// deno run --location http://localhost:8080 my.test.ts
import { FetchHelper } from "https://deno.land/x/fetch_as_class@v1.0.8/mod.ts";
const fetchHepler = new FetchHelper();
import * as t from "https://deno.land/std@0.102.0/testing/asserts.ts";
Deno.test(
"test 1 for get list domain ",
async () => {
fetchHepler.setPathname("/api/todos");
const response = await fetchHepler.GET()
await response.json()
// or await response.text()
// otherwise test will failed with this error
// AssertionError: Test case is leaking resources.
// Before: {
// "0": "stdin",
// "1": "stdout",
// "2": "stderr"
// }
// After: {
// "0": "stdin",
// "1": "stdout",
// "2": "stderr",
// "5": "fetchResponseBody"
// }
t.assertEquals(response.status, 200);
},
);
```