contentful.js
contentful.js copied to clipboard
Add support for cancelable requests
Since this library is using axios under the hood, I think it would be nice to provide a way to pass along the Cancellation token when making a contentful request.
Expected Behavior
I would expect to pass the cancellation token as a param on each request since that's how axios gets the cancel token.
import axios from 'axios';
import contentful from 'contentful';
const contentfulClient = contentful.createClient(contentfulConfig);
const source = CancelToken.source();
contentfulClient.getEntries({ 'fields.id': '1a2b' }, source);
// cancel the request
source.cancel();
Context
This feature would be very useful since we could cancel the request mid-flight if a user changes the page pre-maturely.