A fetch for any HttpTransport client's fetch option: respond answers each request, with a Response or with a plain value sent as a JSON body, and calls records them in order.
fetch
HttpTransport
respond
Response
calls
MDN Reference
Optional
import { NewsClient } from '@datamoc/mwg/core';import { fakeFetch } from '@datamoc/mwg/testing';const fetch = fakeFetch(() => [{ id: '1', title: 'Patch notes', body: 'Fixed things.' }]);const news = new NewsClient({ endpoint: 'https://example.test/news', fetch }); Copy
import { NewsClient } from '@datamoc/mwg/core';import { fakeFetch } from '@datamoc/mwg/testing';const fetch = fakeFetch(() => [{ id: '1', title: 'Patch notes', body: 'Fixed things.' }]);const news = new NewsClient({ endpoint: 'https://example.test/news', fetch });
A
fetchfor anyHttpTransportclient'sfetchoption:respondanswers each request, with aResponseor with a plain value sent as a JSON body, andcallsrecords them in order.