Skip to content

v2.3.0

Compare
Choose a tag to compare
@heenakwag heenakwag released this 28 Jan 06:09
· 19 commits to master since this release

Features

  • ce12fb3 Feat: ajax (#44)
    • A module for the Ajax request. [API Page]
      • If the browser supports Promise, return the Promise object. If not, return null after complete the Ajax call.
      • It supports beforeRequest, success, error, and complete callbacks.
      • Common configurations can be specified in ajax.defaults.
      • It provides ES6(tui-code-snippet/ajax/index.mjs) and transpiled(tui-code-snippet/ajax/index.js) files. Transpiled version supports IE8+.
import ajax from 'tui-code-snippet/ajax'; // import ES6 module (written in ES6)
// import ajax from 'tui-code-snippet/ajax/index.js'; // import transfiled file (IE8+)

ajax({
  url: 'https://nhn.github.io/tui-code-snippet/2.3.0/latest',
  method: 'POST',
  contentType: 'application/json',
  params: {
    version: 'v2.3.0',
    author: 'NHN. FE Development Lab <[email protected]>'
  },
  beforeRequest: () => {
    showProgressBar();
  },
  complete: () => {
    hideProgressBar();
  }
}).then(({ data }) => {
  console.log(data);
}).catch(({ status, statusText }) => {
  console.error(`${status} - ${statusText}`);
});