Axios is not defined

Hi, I see Axios is already installed in package.json, but why is it still causing axios is not defined when we call axios on our script? isn't it already on plugins.bundle.js? Why select2 and sweetalert 2 can be used just using plugins.bundles.js? Thanks.

Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)

Hi,

May I know where you call Axios code ? On document ready event or right after page load ?

// On document ready
KTUtil.onDOMContentLoaded(function() {
// Axios code goes here
});

Regards.

it's inside KTUtil.onDOMContentLoaded(function() {
});

But it's strange, why i can't find axios script on scripts.bundle.js although there is "axios": "^0.21.1",
inside package.json and I see it's already in node_modules folder either? am I missing something?

Oh, it seems we did not include it in the gulp config. Please try to add it in core/html/tools/gulp.config.js and recompile the assets with gulp.

axios: {
scripts: [
"{$config.path.node_modules}/axios/dist/axios.min.js"
],
},

If you are using Webpack please let us know and we will provide the webpack integration. However, in the next update, we will include axios in the build by default.

Regards

Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(