Again, this is something we are familiar with from the custom module that we created in the Writing a basic module section – leveraging the Lodash templates to change the output of the registered plugin by using if-condition blocks. Again, Lodash templates are the blocks of code with which we can interpolate data properties with the <%= %> interpolation delimiters. Let's try another simple example in the following steps:
- Create a plugin file to import axios and add the if-condition blocks to make sure the request URL is provided for axios, and to print the request result on the terminal when your Nuxt app is running in dev mode (npm run dev) for debugging:
// modules/users/plugin.js
import axios from 'axios'
let users = []
<% if (options.url) { %>
users = axios.get('<%= options.url %>')
<% } %>
<% if (options.debug) { %>
// Dev only code
users.then((response) => {
console...