Random scripts I use for many projects.
npm install treeder/jsutils
Then import with:
import {api, apiInit} from 'jsutils/api.js'
import { api, apiInit } from 'https://cdn.jsdelivr.net/gh/treeder/jsutils@0/api.js'
Then just use it in place of fetch:
let r = await api(`/v1/posts`)