Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Tiny JSON fetch wrapper library. ~1.7kb gzipped.
fetchyeah
is a small fetch wrapper library that always parses JSON and returns
JS. Smaller than Axios, Request, R2, and the whatwg-fetch
polyfill itself.
npm i fetchyeah
import { get } from 'fetchyeah'
get('/foo')
del
get
patch
post
put
This only provides functions for these common HTTP methods, but you can easily add
your own. Check out the source for notes on how to use sendJson
directly.
The return value is always a simple response of type
type SimpleResponse<T> = {
ok: boolean
status: number
headers: Headers
body: T
}
Node:
require('isomorphic-fetch') // brings in fetch for Node
import * as f from 'fetchyeah'
// some koa route
router.get('/foo/:id', async (ctx) => {
try {
const thing = await f.get(`/some-service/${id}`)
ctx.type = 'application/json'
ctx.body = thing
} catch (e) {
someLogger.error(e)
ctx.status = 500
ctx.body = e
}
})
Browser:
import * as React from 'react'
import { post } from 'fetchyeah'
class Foo extends React.Component {
state = { things: null }
submitThings = () => {
post('/stuff', { body: this.state.things })
.then((res) => {
if (res) {
alert(res)
}
})
.catch((err) => {
someErrorHandler(err)
})
}
setThings = (e) => {
this.setState({ things: e.target.value })
}
render () {
return (
<React.Fragment>
<input
type="text"
onChange={this.setThings}
value={this.state.things}
/>
<button onClick={submitThings}>
Send the things!
</button>
</React.Fragment>
)
}
}
Adding headers:
import { post } from 'fetchyeah'
post('/foo', {
body: someObject,
headers: {
'x-foo-bar': 'baz',
}
})
This library assumes fetch
is available. You may need to polyfill it!
FAQs
Miniscule JSON fetch wrapper library.
The npm package fetchyeah receives a total of 2 weekly downloads. As such, fetchyeah popularity was classified as not popular.
We found that fetchyeah demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.