Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@gastonyte/cycle-fetch-driver
Advanced tools
A Cycle.js Driver for making HTTP requests through fetch
A Cycle.js Driver for making HTTP requests, using the Fetch API.
npm install @gastonyte/cycle-fetch-driver
FetchDriver({ fetch, ...fetchDefaultOptions }) -> fetchDriver: function
Factory that returns a fetch driver.
It can take an optional fetch
option which allow inversion of control. (defaults to global.fetch)
All other options provided are considered fetch default options.
Basics:
import Stream from 'xstream';
import fetch from 'isomorphic-fetch';
import { run } from '@cycle/run';
import FetchDriver from '@gastonyte/cycle-fetch-driver';
const main = ({ HTTP }) => {
HTTP.filterByKey('anotherKey').debug('response').addListener(response$ => response$);
return {
HTTP: Stream.of(
'http://localhost:3000/api',
{ key: 'oneKey', url: 'http://localhost:3000/api', options: { /* ...overrideFetchOptions */ } },
{ key: 'anotherKey', input: { url: 'http://localhost:3000/api' } }
)
};
};
run(main, {
HTTP: FetchDriver({
fetch,
credentials: 'same-origin'
// ...otherDefaultFetchOptions
})
});
Select all the responses by key or by url:
import Stream from 'xstream';
import { run } from '@cycle/run';
import FetchDriver from '@gastonyte/cycle-fetch-driver';
import fetch from 'isomorphic-fetch';
const main = ({ HTTP }) => {
const HELLO_URL = 'https://jsonplaceholder.typicode.com/posts/1';
const request$ = Stream.of({
key: 'hello',
url: HELLO_URL
});
HTTP.filterByKey('hello') // OR .filterByUrl(HELLO_URL)
.flatten()
.map(response => Stream.fromPromise(response.json()))
.flatten()
.map(json => ({ isLoaded: true, json }))
.startWith({ isLoaded: false })
.addListener({
next: ({ isLoaded, json }) => {
console.log('isLoaded:', isLoaded);
if (isLoaded) {
console.log('json:', json);
}
}
});
return {
HTTP: request$
};
};
run(main, {
HTTP: FetchDriver({
fetch
})
});
FAQs
A Cycle.js Driver for making HTTP requests through fetch
We found that @gastonyte/cycle-fetch-driver demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.