tkrotoff / fetch Goto Github PK
View Code? Open in Web Editor NEWA Fetch API wrapper
License: MIT License
A Fetch API wrapper
License: MIT License
All worldwide (https://gs.statcounter.com/browser-market-share):
Desktop only worldwide (https://gs.statcounter.com/browser-market-share/desktop/worldwide/):
All worldwide (https://gs.statcounter.com/browser-market-share):
Desktop only worldwide (https://gs.statcounter.com/browser-market-share/desktop/worldwide/):
All worldwide (https://gs.statcounter.com/browser-market-share):
Desktop only worldwide (https://gs.statcounter.com/browser-market-share/desktop/worldwide/):
All worldwide (https://gs.statcounter.com/browser-market-share):
Desktop only worldwide (https://gs.statcounter.com/browser-market-share/desktop/worldwide/):
Or let the user create a facade
HTTPError:
HttpError:
Like toJSON()
, JSON.stringify()
...
See also https://github.com/mikeal/bent
https://github.com/lquixada/cross-fetch
I try to use it in the nextjs project, fetch may run on the server side.
Hi:
I see this library sending this header to servers:
'accept-encoding': 'gzip, deflate, br'
and is a header I can't change by the fetch web standard protocol.
but then when the server response is brotli compressed (we accept br), the method
get(...).json()
fails, it seems that brotli uncompress is not supported by this library, or am I missing something?
thanks in advance
.npmignore
with:
dist/cjs/Http.test.js
dist/Http.test.d.ts
dist/Http.test.js
does not work :/
npm publish --dry-run
output:
=== Tarball Contents ===
npm notice 1.8kB package.json
npm notice 577B CHANGELOG.md
npm notice 1.1kB LICENSE
npm notice 619B README.md
npm notice 3.9kB dist/cjs/Http.js
npm notice 10.8kB dist/cjs/Http.test.js
npm notice 467B dist/cjs/HttpError.js
npm notice 1.6kB dist/cjs/HttpStatus.js
npm notice 272B dist/cjs/index.js
npm notice 686B dist/Http.d.ts
npm notice 3.6kB dist/Http.js
npm notice 11B dist/Http.test.d.ts
npm notice 9.9kB dist/Http.test.js
npm notice 126B dist/HttpError.d.ts
npm notice 366B dist/HttpError.js
npm notice 635B dist/HttpStatus.d.ts
npm notice 1.5kB dist/HttpStatus.js
npm notice 83B dist/index.d.ts
npm notice 83B dist/index.js
Line 13 in fe68169
It won't generate any code at runtime.
export function createHttpError(statusText: string, status: HttpStatus, responseBody: object) {
const error = new HttpError(statusText);
error.status = status;
error.response = responseBody;
return error;
}
Instead of (url: string, init?: Init)
, use fetch(input: RequestInfo, init?: RequestInit)
?
See https://twitter.com/lcasdev/status/1564598435772342272
Here: https://github.com/tkrotoff/fetch/blob/v0.16.0/src/createHttpError.ts#L30-L34
new Response(JSON.stringify(body), {
status,
statusText,
headers: { 'content-type': jsonMimeType }
})
becomes
Response.json(body, { status, statusText })
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.