Registry / database / mobx-rest-fetch-adapter

mobx-rest-fetch-adapter

JSON →
library0.1.4jsnpmunverified

A lightweight adapter for mobx-rest that uses the native fetch API to perform HTTP requests. Version 0.1.4 is the latest, but the package appears to be in early development with minimal maintenance. It lacks file upload and progress tracking, which are available in mobx-rest-jquery-adapter. Note that mobx-rest itself is deprecated in favor of mobx-rest-api, making this adapter also obsolete for new projects.

npm install mobx-rest-fetch-adapter
INSTALL
IMPORT
SIG · MOBX-REST-FETCH-AD
M
mobx-rest-fetch-adapter
databasejavascriptv0.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import fetchAdapter from 'mobx-rest-fetch-adapter'
const fetchAdapter = require('mobx-rest-fetch-adapter')
Package is ESM-only. CommonJS require will fail.
fetchAdapter
import { fetchAdapter } from 'mobx-rest-fetch-adapter'
import fetchAdapter from 'mobx-rest-fetch-adapter'
Named export is also available, but default import is more common.
configure
import { configure } from 'mobx-rest-fetch-adapter'
const { configure } = require('mobx-rest-fetch-adapter')
Used for configuring the adapter; ESM-only.

Configures the fetch adapter with custom headers and credentials, then creates a mobx-rest model and saves a new todo.

import { configure } from 'mobx-rest-fetch-adapter'; import { createModel } from 'mobx-rest'; configure({ headers: { 'Content-Type': 'application/json' }, credentials: 'same-origin' }); const Todo = createModel('todos'); const todo = new Todo({ title: 'Get milk' }); todo.save().then(() => console.log('Saved'));
Debug
Known issues
deprecatedmobx-rest is deprecated in favor of mobx-rest-api. This fetch adapter is no longer maintained and should not be used for new projects.
fix
Migrate to mobx-rest-api and use the integrated fetch support or another adapter.
affects: >=0.0.0
gotchaFile upload and progress tracking are not supported by this adapter.
fix
Use mobx-rest-jquery-adapter if you need these features, or implement your own adapter.
affects: >=0.0.0
gotchaThe package is ESM-only and will not work with require() in Node.js without proper configuration.
fix
Use import syntax and ensure your project is set up for ES modules.
affects: >=0.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module
Using require() to import an ESM-only package.
fix
Use import { fetchAdapter } from 'mobx-rest-fetch-adapter' or set type: module in package.json.
TypeError: fetch is not a function
The fetch API is not available in the environment (e.g., older Node.js).
fix
Install a fetch polyfill like 'whatwg-fetch' or use Node 18+ with native fetch.
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies
mobx-restrequiredThis adapter is designed to work with mobx-rest, which is deprecated.
Agent activity
9 hits · last 30 days
node
8
Resources
mobx-rest-fetch-adapter — npm install mobx-rest-fetch-adapter · libregistry