{"_id":"@eliasrrosa/mock-fetch","_rev":"3-7f63c193d1601c7ed4047a69e2bf958e","name":"@eliasrrosa/mock-fetch","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.2":{"name":"@eliasrrosa/mock-fetch","version":"0.0.2","keywords":["mock","front-end"],"author":{"name":"Elias Rosa"},"_id":"@eliasrrosa/mock-fetch@0.0.2","maintainers":[{"name":"eliasrrosa","email":"elias_rrosa@hotmail.com"}],"homepage":"https://github.com/E-Rosa/mock-fetch#readme","bugs":{"url":"https://github.com/E-Rosa/mock-fetch/issues"},"dist":{"shasum":"b6b3d78994d24b4df7b7c33c959f04b731fd1368","tarball":"https://registry.npmjs.org/@eliasrrosa/mock-fetch/-/mock-fetch-0.0.2.tgz","fileCount":4,"integrity":"sha512-a7Pa2dK8KqhtdClm9lBppyWjmjq6c/C24rbinMWtLHQfyZitUC5lbvgUI8blgkJOYERdsxkyIJJ8575SmX6RgQ==","signatures":[{"sig":"MEQCICmdszVkrEcA6NzsRznumqAp92pPVpfCG/KtXWXP+VdfAiBR1uAoux6ngEdGVyi/uZhIJXmrZ84zRh4a5uLtdwTJ7g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":2903},"main":"dist/index.js","types":"./dist/index.d.ts","access":"public","scripts":{"test":"jest --watch"},"_npmUser":{"name":"eliasrrosa","email":"elias_rrosa@hotmail.com"},"repository":{"url":"git+ssh://git@github.com/E-Rosa/mock-fetch.git","type":"git"},"_npmVersion":"9.6.3","description":"An API that simulates (some of) the behavior of the browser's fetch() api.","directories":{},"_nodeVersion":"19.9.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mock-fetch_0.0.2_1740317892323_0.5288304378489657","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@eliasrrosa/mock-fetch","version":"0.0.3","keywords":["mock","front-end"],"author":{"name":"Elias Rosa"},"_id":"@eliasrrosa/mock-fetch@0.0.3","maintainers":[{"name":"eliasrrosa","email":"elias_rrosa@hotmail.com"}],"homepage":"https://github.com/E-Rosa/mock-fetch#readme","bugs":{"url":"https://github.com/E-Rosa/mock-fetch/issues"},"dist":{"shasum":"9be55167e3a5b854e67fff1f4cb155a46974db1d","tarball":"https://registry.npmjs.org/@eliasrrosa/mock-fetch/-/mock-fetch-0.0.3.tgz","fileCount":4,"integrity":"sha512-i5Drn4HuT3XvbMlUXvT8cNjiK5ZXLmmlG4wK9M/TarawvmbjUAVD2zp5TdbarsmI/IVZt7Cc1QATllvzUdI/mQ==","signatures":[{"sig":"MEYCIQDaBpaw1aDERLWPi46XQNJNOkCtD0ssDRBzfE57A0gBVQIhAO+peumWl11ur2saM9VUFPryk80M+C9iXTjOAuPm/PxR","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":2903},"main":"dist/index.js","types":"./dist/index.d.ts","access":"public","scripts":{"test":"jest --watch"},"_npmUser":{"name":"eliasrrosa","email":"elias_rrosa@hotmail.com"},"repository":{"url":"git+ssh://git@github.com/E-Rosa/mock-fetch.git","type":"git"},"_npmVersion":"9.6.3","description":"An API that simulates (some of) the behavior of the browser's fetch() api.","directories":{},"_nodeVersion":"19.9.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mock-fetch_0.0.3_1740317904578_0.9833421985205206","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@eliasrrosa/mock-fetch","version":"0.0.4","keywords":["mock","front-end"],"author":{"name":"Elias Rosa"},"_id":"@eliasrrosa/mock-fetch@0.0.4","maintainers":[{"name":"eliasrrosa","email":"elias_rrosa@hotmail.com"}],"homepage":"https://github.com/E-Rosa/mock-fetch#readme","bugs":{"url":"https://github.com/E-Rosa/mock-fetch/issues"},"dist":{"shasum":"ec2fa2aa1e675f133b94195fa74648e133e5ac1f","tarball":"https://registry.npmjs.org/@eliasrrosa/mock-fetch/-/mock-fetch-0.0.4.tgz","fileCount":4,"integrity":"sha512-iEbdyGZo8EeBNNfyrdXBQbjz6d9zuudcDGGbeWztbjGrzu+TH6W7faMu0XmyZMR4ajgKCQWrlgxgoFQN1I35aQ==","signatures":[{"sig":"MEUCIQDqdlj46l+ZRKuzZCzo4v0SwwWivtNN8Ls7kCI8sCP34AIgQRMxM9Fya6ezkH4miajywbhsvngL2rWC+OTipUC4Fso=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":2902},"main":"dist/index.js","types":"./dist/index.d.ts","access":"public","scripts":{"test":"jest --watch"},"_npmUser":{"name":"eliasrrosa","email":"elias_rrosa@hotmail.com"},"repository":{"url":"git+ssh://git@github.com/E-Rosa/mock-fetch.git","type":"git"},"_npmVersion":"9.6.3","description":"An API that simulates (some of) the behavior of the browser's fetch() api.","directories":{},"_nodeVersion":"19.9.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mock-fetch_0.0.4_1740318234097_0.8696447135270671","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"@eliasrrosa/mock-fetch","version":"0.0.5","access":"public","description":"An API that simulates (some of) the behavior of the browser's fetch() api.","main":"dist/index.js","scripts":{"test":"jest --watch"},"repository":{"type":"git","url":"git+ssh://git@github.com/E-Rosa/mock-fetch.git"},"keywords":["mock","front-end"],"author":{"name":"Elias Rosa"},"bugs":{"url":"https://github.com/E-Rosa/mock-fetch/issues"},"homepage":"https://github.com/E-Rosa/mock-fetch#readme","types":"./dist/index.d.ts","gitHead":"8b04ff8d44081eab877efc822c6ac4eaab3227ca","_id":"@eliasrrosa/mock-fetch@0.0.5","_nodeVersion":"19.9.0","_npmVersion":"9.6.3","dist":{"integrity":"sha512-OSzpNpSY3p3+CCO80ufreIqyqwjWxahzMmEqhDno44kS9dvNkw5rMpj96xUn2uHinZ2XiTviSBhYpYyHPzTSGg==","shasum":"eb0dd27ee4148ee8168af7ccdc2c90fa95fc0ca2","tarball":"https://registry.npmjs.org/@eliasrrosa/mock-fetch/-/mock-fetch-0.0.5.tgz","fileCount":4,"unpackedSize":2911,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIG4XrNTB3D2EWAxsv8TOSGl/53oCW5g2Nsx/e5N7GSY+AiEA/It5SOrKEHJCAoGzU6F6H1JFJRYaE8I2A1WrUFBMB6w="}]},"_npmUser":{"name":"eliasrrosa","email":"elias_rrosa@hotmail.com"},"directories":{},"maintainers":[{"name":"eliasrrosa","email":"elias_rrosa@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mock-fetch_0.0.5_1740318397281_0.9316435781120012"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-23T13:38:12.251Z","modified":"2025-02-23T13:46:37.678Z","0.0.2":"2025-02-23T13:38:12.532Z","0.0.3":"2025-02-23T13:38:24.761Z","0.0.4":"2025-02-23T13:43:54.281Z","0.0.5":"2025-02-23T13:46:37.466Z"},"bugs":{"url":"https://github.com/E-Rosa/mock-fetch/issues"},"author":{"name":"Elias Rosa"},"homepage":"https://github.com/E-Rosa/mock-fetch#readme","keywords":["mock","front-end"],"repository":{"type":"git","url":"git+ssh://git@github.com/E-Rosa/mock-fetch.git"},"description":"An API that simulates (some of) the behavior of the browser's fetch() api.","maintainers":[{"name":"eliasrrosa","email":"elias_rrosa@hotmail.com"}],"readme":"# Mock Fetch\n\nTest your front-end without connecting to an external API using mock-fetch.\n\n# Installation\n\nRun:\n\n```\nnpm i @eliasrrosa/mock-fetch@latest\n```\n\n# Usage\n\nInstead of calling `fetch()` call `MockFetch.fetch()` with a callback, and return `new MockResponse()`. Optionally set `fetchTimeoutInMs` to control the request time.\n\n```js\nimport { MockFetch, MockResponse, MockBody } from \"@eliasrrosa/mock-fetch\";\n\nfunction fetchBooks() {\n  return MockFetch.fetch(() => {\n    return new MockResponse({\n      body: new MockBody([{ title: \"Book 1\" }, { title: \"Book 2\" }]),\n      status: 200,\n    });\n  }, { fetchTimeoutMs: 2000});\n}\n```\n\nThe returned object will have properties that mock the return object of `fetch()`.\n\n```js\nconst res = await fetchBooks();\n\nconsole.log(res.status);       //returns 200\nconsole.log(res.body.data);    //returns \"[{\"title\":\"Book 1\"},{\"title\":\"Book 2\"}]\" \nconsole.log(await res.json()); //returns [{ title: \"Book 1\" }, { title: \"Book 2\" }]\n\n```\n","readmeFilename":"README.md"}