UNPKG

@splitsoftware/splitio-commons

Version:
15 lines (14 loc) 648 B
/** * Factory of MySegments fetcher. * MySegments fetcher is a wrapper around `mySegments` API service that parses the response and handle errors. */ export function mySegmentsFetcherFactory(fetchMemberships) { return function mySegmentsFetcher(userMatchingKey, noCache, till, // Optional decorator for `fetchMemberships` promise, such as timeout or time tracker decorator) { var mySegmentsPromise = fetchMemberships(userMatchingKey, noCache, till); if (decorator) mySegmentsPromise = decorator(mySegmentsPromise); return mySegmentsPromise.then(function (resp) { return resp.json(); }); }; }