Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.

Latest commit

 

History

History
31 lines (19 loc) · 1.09 KB

3.external-packages.md

File metadata and controls

31 lines (19 loc) · 1.09 KB
title External Packages Plugin
description In this example we show how to use a plugin with an external package - axios
category plugins

External Packages Plugin

In this example we show how to use a plugin with an external package - axios


In this example:

plugins/axios.js intercepts the $axios call using the onError() function.

pages/index.vue uses $axios to fetch our data from an API.

pages/mountains/_slug.vue uses $axios to fetch our data from an API with the id coming from route params.

pages/404.vue is the page that is called when there is an error.

nuxt.config.js contains the module property and plugin property to register our module and plugin.

package.json shows our module @nuxtjs/axios has been installed.

::alert{type="next"} Learn more in the Directory Structure book in the plugins chapter. ::

:sandbox{src="https://codesandbox.io/embed/github/nuxtlabs/examples/tree/master/plugins/external-packages-plugin?fontsize=14&hidenavigation=1&module=%2Fplugins%2Faxios.js&theme=dark&view=editor"}