fayfetch
Simple fetch wrapper for JavaScript and Node.js. Make GET, POST, PUT, DELETE and file upload calls in one line with params and headers
- Platform
- Libraries
- Category
- Developer Tools
- Available from
- npm
About this app
fayfetch is a simple wrapper around fetch for JavaScript and Node.js. Calling a REST API with plain fetch means building the query string, setting headers, turning the body into JSON and checking the response every time. fayfetch does that for you: pass the URL, params, headers and body, and get the status and the JSON back in one callback.
I made it back when I didn't know much JavaScript yet, and TypeScript even less. I wanted a quick, hacky way to make fetch calls as easy as possible for me. I know it's not the best way to do it, but I gave it a try.
- One line per request:
get,post,putanddeleteewith params, headers and a body. - File uploads: upload a file, or send your own
FormData. - One simple callback: you get the status code, the JSON data and whether it worked.
- Works with
requireorimport.
Great for small Node.js scripts and apps that talk to a REST API.
Install
npm install fayfetch
import { FayFetch } from 'fayfetch'
FayFetch.get(url, params, headers, (status, jsonData, ok) => {
if (ok) console.log(jsonData)
})
Want a clean API layer for your JavaScript project? Contact me through my portfolio: https://p32929.github.io