UNPKG

nuxt-isomorphic-fetch

Version:

Isomorphic access to server-side API in Nuxt.js asyncData

15 lines (14 loc) 303 B
export default function(path, body, opts) { if (typeof path === "object") { opts = {...path} } else { opts = {...opts, path, body} } if (!opts.path) { throw new Error("fetch: path required.") } if (!opts.method) { opts.method = (opts.body === undefined) ? 'GET' : 'POST' } return opts }