A lightweight RESTful API wrapper around window.fetch for browser and React Native environments. Version 2.0.4 focuses on simplicity: no Babel or ES2015 dependencies, making it smoother for React Native. It automatically handles JSON headers and responses, and offers methods like get, post, put, patch, del, and rawGet. The library uses URI.js for robust URL parsing. It is best suited for simple REST API interactions where manual fetch configuration is unwanted.
npm install fetch-on-restNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic initialization, GET, POST, and DELETE (del) requests with query params and JSON body.
Replace all `.delete` calls with `.del`.
Ensure `addOptions` modifies `defaultOptions` directly without returning.
Check response status inside the then handler or use a custom wrapper.
Only use `rawGet` when you expect a text response.
Set `useTrailingSlashes` to true or ensure `basePath` ends with '/'.
Use `const Rest = require('fetch-on-rest');` then `new Rest();`Replace `api.delete(...)` with `api.del(...)`.
Use `.get` instead of `.rawGet` for JSON responses, or parse manually.
Set `basePath` to end with '/' or enable `useTrailingSlashes`.