jsFetchMock
A simple lib to intercept Javascript fetch to capture or edit the data
Summary
| Latest Version | 0.1.1 |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:25 |
Tags
Authors
- Thiago Navarro
Installation
nimble install jsFetchMock
choosenim install jsFetchMock
git clone https://github.com/thisago/jsfetchMock
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| jsFetchMock | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Dependencies
| Package | Version | Optional |
|---|---|---|
| nim >= | 1.6.4 | No |
Source
| Repository | https://github.com/thisago/jsfetchMock |
|---|---|
| Homepage | https://github.com/thisago/jsfetchMock |
| Registry Source | nimble_official |
README
JS Fetch Mock
A simple lib to intercept Javascript fetch to capture or edit the data
You can use it in Nim and Javascript!
Examples
Javascript
You can see the full example at example/js
newFetchMock("example", (err, url, response, config) => {
return `{"name": "John"}` // check, edit and replace the data here
})
fetch("../data.json")
.then((x) => x.text())
.then((txt) => {
console.log(txt)
})
deleteFetchMock("example")
Nim
You can see the example mocking a JS fetch at example/nim
Documentation
template newFetchMock*(name: cstring; cb: untyped): untyped
Add a mock with name and callback
It exposes to cb: error, url, body and configs
Example:
discard newFetchMock("example"):
echo body
proc deleteFetchMock*(name: cstring): bool
Removes the mock by name
Example:
discard deleteFetchMock("example")
License
MIT