Gathering detailed insights and metrics for gofor
Gathering detailed insights and metrics for gofor
Gathering detailed insights and metrics for gofor
Gathering detailed insights and metrics for gofor
npm install gofor
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1 Stars
34 Commits
2 Forks
68 Watching
57 Branches
253 Contributors
Updated on 10 Feb 2021
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-28.9%
576
Compared to previous day
Last week
13.1%
3,486
Compared to previous week
Last month
35%
14,668
Compared to previous month
Last year
72%
278,133
Compared to previous year
2
5
Each Gofor instance exposes a fetch method: a lean, isomorphic fetch decorator that deep reverse merges default options.
Options you pass through in for each request will take precedence, but will supplemented with the defaults.
npm i gofor
Gofor
class1const Gofor = require('gofor'); 2const myGofor = new Gofor({headers: {'X-Custom-Header': 'Custom-Value'}}); 3 4myGofor.fetch('/page') 5 .then(...) 6 .catch(...);
You can opt to import the gofor
property to get a working instance with the default environment Headers
:
1const { gofor } = require('gofor'); 2 3gofor('/page').then(...); // This is the fetch
Each call to Gofor.gofor
generates a new instance:
1const gofor1 = require('gofor').gofor; 2const gofor2 = require('gofor').gofor; 3 4gofor1 === gofor2 // false
1const { gofor } = require('gofor'); 2const defaultHeaders = new Headers(); 3 4defaultHeaders.append('X-Requested-With', 'XMLHttpRequest'); 5defaultHeaders.append('Content-Type', 'application/json; charset=utf-8'); 6defaultHeaders.append('Accept', 'application/json'); 7 8gofor.config({ 9 credentials: 'same-origin', 10 headers: defaultHeaders 11}); 12 13// Use only defaults 14gofor('https://www.website.com').then(...); 15 16// Add/Apply other options 17gofor('/page', { 18 headers: { 19 'X-Custom-Header': 'Custom-Value' 20 } 21}).then(...);
Headers
Gofor
supports setting headers either as an object literal or as a Headers
instance
Default header keys will be run over if matched by passed in header keys. Other keys will be merged. This is made by design.
1// Configure using the "Headers" constructor 2 3gofor.config({ 4 credentials: 'same-origin', 5 headers: new Headers({ 6 'Content-Type': 'application/json; charset=utf-8', 7 'X-Custom-Header': 'Custom-Value' 8 }) 9}); 10 11// Or, using an object literal 12 13gofor.config({ 14 credentials: 'same-origin', 15 headers: { 16 'Content-Type': 'application/json; charset=utf-8', 17 'X-Custom-Header': 'Custom-Value' 18 } 19}); 20 21gofor('/page', { 22 headers: new Headers({ 23 'Content-Type': 'text/plain', 24 }) 25});
Final headers will be:
1 'Content-Type': 'text/plain', 2 'X-Custom-Header': 'Custom-Value'
The function will be called once on first use, and its result will be memoised. useful for cases where you need to pull information from the document and don't want to create a race condition.
1const { gofor } = require('gofor'); 2 3gofor.config(() => ({ 4 credentials: 'same-origin', 5 headers: { 6 'X-Requested-With': 'XMLHttpRequest', 7 'Content-Type': 'application/json; charset=utf-8', 8 'Accept': 'application/json', 9 'X-Custom-Secret': document.getElementById('secret').value, 10 }, 11}));
The two breaking changes in version 3 are:
gofor/server
) in favor of a truly isomorphic solution.dist
folder.No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
branch protection is not maximal on development and all release branches
Details
Reason
Found 11/27 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
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