Skip to content

Instantly share code, notes, and snippets.

@kellenmace
Created March 18, 2021 16:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellenmace/b9d34dc4eb569e75644391851fef5ad3 to your computer and use it in GitHub Desktop.
Save kellenmace/b9d34dc4eb569e75644391851fef5ad3 to your computer and use it in GitHub Desktop.
Dynamically import an NPM module from dev.jspm.io to try it out
// Dynamically import an NPM module from dev.jspm.io to try it out.
// Run this in your browser console.
(async function() {
const axios = (await import('https://dev.jspm.io/axios')).default;
const response = await axios.get('https://pokeapi.co/api/v2/pokemon/');
console.log(response.data);
})();
@kellenmace
Copy link
Author

kellenmace commented Mar 24, 2021

Note:
This code won't work on this GitHub Gist page, since cross-origin requests violate their content security policy. 🤓

Try it somewhere else, like https://kellenmace.com, https://www.google.com, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment