Gathering detailed insights and metrics for ember-fetch
Gathering detailed insights and metrics for ember-fetch
Gathering detailed insights and metrics for ember-fetch
Gathering detailed insights and metrics for ember-fetch
ember-fetch-tsdefs
type defs for ember-fetch
ember-cli-app-version
Adds App version number to Ember Inspector Info Tab
ember-fetch-adapter
A Network Adapter Service based on Ember RFC #171.
@ember-data/request
⚡️ A simple, small and fast framework-agnostic library to make `fetch` happen
HTML5 fetch polyfill from github wrapped and bundled for ember-cli users.
npm install ember-fetch
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
176 Stars
733 Commits
80 Forks
13 Watching
34 Branches
58 Contributors
Updated on 08 Nov 2024
JavaScript (84.9%)
TypeScript (9.13%)
Perl (2.81%)
HTML (2.51%)
Handlebars (0.65%)
Cumulative downloads
Total Downloads
Last day
1.3%
12,142
Compared to previous day
Last week
-4.9%
61,450
Compared to previous week
Last month
9.3%
296,871
Compared to previous month
Last year
3.7%
4,705,126
Compared to previous year
14
45
HTML5 fetch polyfill from github wrapped and bundled for ember-cli users.
ember install ember-fetch
ember-fetch requries ember-cli 2.13 or above.
1import Route from '@ember/routing/route'; 2import fetch from 'fetch'; 3 4export default Route.extend({ 5 model() { 6 return fetch('/my-cool-end-point.json').then(function(response) { 7 return response.json(); 8 }); 9 } 10});
Available imports:
1import fetch, { Headers, Request, Response, AbortController } from 'fetch';
To use ember-fetch
with TypeScript or enable editor's type support, You can add "fetch": ["node_modules/ember-fetch"]
to your tsconfig.json
.
1{ 2 "compilerOptions": { 3 "paths": { 4 "fetch": [ 5 "node_modules/ember-fetch" 6 ] 7 } 8 } 9}
ember-data@3.9.2 was released with built-in fetch support, if your ember-data is below 3.9.2, please checkout ember-fetch v7.x.
ember-fetch
uses node-fetch
in Fastboot, which doesn't allow relative URL.
url
should be an absolute url, such ashttps://example.com/
. A path-relative URL (/file/under/root
) or protocol-relative URL (//can-be-http-or-https.com/
) will result in a rejected promise.
However, ember-fetch
grabs the protocol
and host
info from fastboot request after the instance-initializes
.
This allows you to make a relative URL request unless the app is not initialized, e.g. initializers
and app.js
.
For addon authors, if the addon supports Fastboot mode, ember-fetch
should also be listed as a peer dependency.
This is because Fastboot only invokes top-level addon's updateFastBootManifest
(detail), thus ember-fetch
has to be a top-level addon installed by the host app.
ember-fetch
allows access to native fetch in browser through a build config flag:
1// ember-cli-build.js
2let app = new EmberAddon(defaults, {
3 // Add options here
4 'ember-fetch': {
5 preferNative: true
6 }
7});
If set to true
, the fetch polyfill will be skipped if native fetch
is available,
otherwise the polyfilled fetch
will be installed during the first pass of the vendor js file.
If set to false
, the polyfilled fetch
will replace native fetch
be there or not.
If all your browser targets support native fetch
, and preferNative: true
, the polyfill will not be included in the output build. If, for some reason, you still need the polyfill to be included in the bundle, you can set alwaysIncludePolyfill: true
.
The way you do import remains same.
If you do not want to use RSVP, but native Promises, you can specify this build config flag:
1// ember-cli-build.js
2let app = new EmberAddon(defaults, {
3 // Add options here
4 'ember-fetch': {
5 nativePromise: true
6 }
7});
A fetch
response is successful if response.ok
is true,
otherwise you can read the status code to determine the bad response type.
fetch
will only reject with network errors.
ember-fetch
provides some utility functions:
isBadRequestResponse
(400)isUnauthorizedResponse
(401)isForbiddenResponse
(403)isNotFoundResponse
(404)isConflictResponse
(409)isGoneResponse
(410)isInvalidResponse
(422)isServerErrorResponse
(5XX)isAbortError
Aborted network error1import Route from '@ember/routing/route'; 2import fetch from 'fetch'; 3import { 4 isAbortError, 5 isServerErrorResponse, 6 isUnauthorizedResponse 7} from 'ember-fetch/errors'; 8 9export default Route.extend({ 10 model() { 11 return fetch('/omg.json') 12 .then(function(response) { 13 if (response.ok) { 14 return response.json(); 15 } else if (isUnauthorizedResponse(response)) { 16 // handle 401 response 17 } else if (isServerErrorResponse(response)) { 18 // handle 5xx respones 19 } 20 }) 21 .catch(function(error) { 22 if (isAbortError(error)) { 23 // handle aborted network error 24 } 25 // handle network error 26 }); 27 } 28});
fetch
support.node_modules
, so we should be resilient to changes assuming
semver from the fetch moduleNo vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/10 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
82 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More