Skip to content

Instantly share code, notes, and snippets.

Created September 16, 2016 18:31
Show Gist options
  • Save anonymous/4391d4c1f77868b95a3a757dc040a017 to your computer and use it in GitHub Desktop.
Save anonymous/4391d4c1f77868b95a3a757dc040a017 to your computer and use it in GitHub Desktop.
const stringfy = (value) => JSON.stringify([value]);
const stringfyAndTransformToObject = (value) => ({ object: stringfy(value) })
const makeRequest = () => {
const context = arguments[0] || this;
const post = (url, data, options) => context.$http(url, stringfyAndTransformToObject(data), options);
return { post };
};
const install = (VueInstance) => {
Object.defineProperties(VueInstance.prototype, {
$request: {
get() {
return makeLoader(this);
},
},
});
};
export default { install };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment