![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
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
classconst Gofor = require('gofor');
const myGofor = new Gofor({headers: {'X-Custom-Header': 'Custom-Value'}});
myGofor.fetch('/page')
.then(...)
.catch(...);
You can opt to import the gofor
property to get a working instance with the default environment Headers
:
const { gofor } = require('gofor');
gofor('/page').then(...); // This is the fetch
Each call to Gofor.gofor
generates a new instance:
const gofor1 = require('gofor').gofor;
const gofor2 = require('gofor').gofor;
gofor1 === gofor2 // false
const { gofor } = require('gofor');
const defaultHeaders = new Headers();
defaultHeaders.append('X-Requested-With', 'XMLHttpRequest');
defaultHeaders.append('Content-Type', 'application/json; charset=utf-8');
defaultHeaders.append('Accept', 'application/json');
gofor.config({
credentials: 'same-origin',
headers: defaultHeaders
});
// Use only defaults
gofor('https://www.website.com').then(...);
// Add/Apply other options
gofor('/page', {
headers: {
'X-Custom-Header': 'Custom-Value'
}
}).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.
// Configure using the "Headers" constructor
gofor.config({
credentials: 'same-origin',
headers: new Headers({
'Content-Type': 'application/json; charset=utf-8',
'X-Custom-Header': 'Custom-Value'
})
});
// Or, using an object literal
gofor.config({
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json; charset=utf-8',
'X-Custom-Header': 'Custom-Value'
}
});
gofor('/page', {
headers: new Headers({
'Content-Type': 'text/plain',
})
});
Final headers will be:
'Content-Type': 'text/plain',
'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.
const { gofor } = require('gofor');
gofor.config(() => ({
credentials: 'same-origin',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/json; charset=utf-8',
'Accept': 'application/json',
'X-Custom-Secret': document.getElementById('secret').value,
},
}));
The two breaking changes in version 3 are:
gofor/server
) in favor of a truly isomorphic solution.dist
folder.FAQs
Lean, isomorphic fetch decorator that reverse merges default options
The npm package gofor receives a total of 4,650 weekly downloads. As such, gofor popularity was classified as popular.
We found that gofor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.