POSTreq
POSTreq (abbr. POST request, acrn. postMessage Fetch Request) is a minimal JavaScript library that works around Neocities’ Content Security Policy limitations on free accounts by wrapping the Fetch API into an iframe.
Note that POSTreq is still in beta and you might discover some bugs!
Try it!
https://postrequest.neocities.org (alternate: https://postreq.jbc.lol)
Installation
-
You’ll need the POSTreq library. You can use either of these:
- Using NPM (for JS frameworks)
Terminal window $ npm install postreq$ bun install postreq - Using jsDelivr (for anything else)
<script src="https://cdn.jsdelivr.net/npm/postreq/dist/postreq.min.js"></script>
- Using NPM (for JS frameworks)
-
Now, you can import and use POSTreq!
// if you're using NPMimport { POSTreq } from 'postreq';const pt = new POSTreq();// if you're using jsDelivrconst pt = new POSTreq.POSTreq();// then you can now fetch stuff! Most of the Fetch API is supported.pt.onLoad = async () => {const res = await pt.fetch('https://gh.jbc.lol/buttons.json');const buttons = await res.json();}// if you want to, you can replace the JS fetch to POSTreq!window.fetch = pt.getPolyfill()
Notes
- Due to issues, POSTreq doesn’t output the entire Response object.
- But, unlike JS Fetch, you can immediately access the data using
text()
,blob()
,json()
,formData()
, andarrayBuffer()
! Note that these are still async objects. - POSTreq does not support response streaming and Keep-Alive.