Home

Issue: 537

FeatherJS Client globally not visible

[issue link]

Hi Guys,
I am totally new to nuxt.js.Tried to integrate nuxt.js with featherjs successfully when i tried to include featherjs client as plugin so that i could call it globally across all my component’s it’s not attaching to the VueJS instance,
my package.json
{
“name”: “nuxt-i18n”,
“dependencies”: {
“axios”: “^0.15.3”,
“bootstrap”: “^3.3.7”,
“feathers”: “^2.1.1”,
“feathers-client”: “^2.0.0-pre.2”,
“feathers-localstorage”: “^1.0.0”,
“feathers-socketio”: “^1.5.2”,
“jquery”: “^3.2.1”,
“nuxt”: “latest”,
“socket.io-client”: “^1.7.3”
},
“scripts”: {
“dev”: “nuxt”,
“build”: “nuxt build”,
“start”: “nuxt start”
}
}

my nuxt.config.js
const webpack = require(‘webpack’)

module.exports = {
loading: {
color: ‘green’
},
router: {
middleware: ‘i18n’
},
build: {
vendor: [‘axios’,‘jquery’, ‘bootstrap’,‘socket.io-client’,‘feathers’,‘feathers-client’,‘feathers-hooks’,‘feathers-socketio’,‘feathers-authentication-client’],
plugins: [
// set shortcuts as global for bootstrap
new webpack.ProvidePlugin({
$: ‘jquery’,
jQuery: ‘jquery’,
‘window.jQuery’: ‘jquery’
})
]
},
css: [‘bootstrap/dist/css/bootstrap.css’],
plugins: [{src: ‘~plugins/bootstrap.js’,ssr:false},
{src:’~plugins/i18n’,ssr:true},
{src:’~plugins/feathers’,ssr:false}]
}

my plugins/feathers.js
import feathers from ‘feathers/client’;
import hooks from ‘feathers-hooks’;
import socketio from ‘feathers-socketio/client’;
import io from ‘socket.io-client’;
import localstorage from ‘feathers-localstorage’;
import authentication from ‘feathers-authentication-client’;
import Vue from ‘vue’

if (process.BROWSER_BUILD) {
const client = feathers().
configure(socketio(io(“http://localhost:3030”))).
configure(hooks()).
configure(authentication({ storage: window.localStorage }));
console.log(“Loading Feather’s Client Globally”);
Vue.prototype.$feathersClient = function () {
console.log(“Returning Client”);
return client;
}
}

My Home.vue which is the one throwing error,

Can someone throw some light on what mistake am i doing…

This question is available on Nuxt.js community (#c463)