import { MagicController } from "../magic"; export const jsonServerPlugin: MagicController = { url: "http://localhost:3000/users/1", get(key) { return fetch(this.url) .then(res => res.json()) .then(parsed => parsed[key]); }, set(key, value) { return fetch(this.url, { body: JSON.stringify({ [key]: value }), headers: new Headers({ "Content-Type": "application/json" }), method: "PATCH" }); } };