diff --git a/examples/with-sockets/nuxt.config.js b/examples/with-sockets/nuxt.config.js index 538c237f8f27..34e2ec30a1bf 100644 --- a/examples/with-sockets/nuxt.config.js +++ b/examples/with-sockets/nuxt.config.js @@ -1,4 +1,4 @@ -export default { +module.exports = { head: { meta: [ { charset: 'utf-8' }, diff --git a/examples/with-sockets/pages/index.vue b/examples/with-sockets/pages/index.vue index fe944f6c0dd6..180e464a4f8b 100644 --- a/examples/with-sockets/pages/index.vue +++ b/examples/with-sockets/pages/index.vue @@ -4,10 +4,10 @@
  • @@ -21,13 +21,13 @@ import socket from '~/plugins/socket.io.js' export default { - asyncData (context, callback) { - socket.emit('last-messages', function (messages) { - callback(null, { - messages, - message: '' - }) - }) + asyncData () { + return new Promise(resolve => + socket.emit('last-messages', messages => resolve({ messages })) + ) + }, + data () { + return { message: '' } }, watch: { messages: 'scrollToBottom' diff --git a/examples/with-sockets/server.js b/examples/with-sockets/server.js index 648f7427e048..cbfd30136d4e 100644 --- a/examples/with-sockets/server.js +++ b/examples/with-sockets/server.js @@ -1,16 +1,12 @@ -import http from 'http' - -import { Nuxt, Builder } from 'nuxt' -import express from 'express' -import SocketIO from 'socket.io' - const port = process.env.PORT || 3000 const isProd = process.env.NODE_ENV === 'production' -const app = express() +const http = require('http') +const app = require('express')() const server = http.createServer(app) -const io = SocketIO(server) +const io = require('socket.io')(server) +const { Nuxt, Builder } = require('nuxt') // We instantiate Nuxt.js with the options const config = require('./nuxt.config.js') config.dev = !isProd