Skip to content

Instantly share code, notes, and snippets.

const delay = (millis) =>
new Promise((resolve, reject) => {
setTimeout((_) => resolve(), millis);
});
async function postData(url = '', data = {}) {
// Default options are marked with *
const response = await fetch(url, {
method: 'POST', // *GET, POST, PUT, DELETE, etc.
mode: 'cors', // no-cors, *cors, same-origin