File Editor
Directories:
.. (Back)
Files:
capabilities.js
code-snippets-library.js
config.js
constants.js
i18n.js
request.js
Create New File
Create
Edit File: request.js
// External dependencies. import $ from 'jquery'; // Internal dependencies. import config from './config'; export const request = (method, data, options = {}) => { const deferred = $.ajax({ type: method, url: config.api, dataType: 'json', data, ...options, }); return Promise.resolve(deferred.promise()) .then(response => { if (false === response.success) { return Promise.reject(response.data || {}); } return Promise.resolve(response.data); }); }; export const post = (data, options = {}) => request('POST', data, options); export const download = url => { const deferred = $.ajax({ type: 'GET', url, }); return Promise.resolve(deferred.promise()) .then(response => { if (false === response.success) { return Promise.reject(response || {}); } return Promise.resolve(response); }); };
Save Changes
Rename File
Rename