Skip to content

Instantly share code, notes, and snippets.

@RiFi2k
Created March 20, 2019 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RiFi2k/5a5a806292e1d6cf9dc7416b81c1b7f8 to your computer and use it in GitHub Desktop.
Save RiFi2k/5a5a806292e1d6cf9dc7416b81c1b7f8 to your computer and use it in GitHub Desktop.
import Qs from 'qs';
import axios from 'axios';
// Axios defaults.
axios.defaults.baseURL = smu.siteurl;
axios.defaults.headers.post['Content-Type'] =
'application/x-www-form-urlencoded';
axios.defaults.transformRequest = data => Qs.stringify(data);
// Async await request
const [initErr, initResponse] = await to(
this.$http.post(smu.ajaxurl, {
action: 'init_task',
task_screen: 'edit',
task_id: this.task.id
})
);
if (initErr) throw new Error('Failed on ajax callback init_task');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment