question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’m trying to use vue-resource together with vuejs 2.0 and server side rendering. Is this possible now? I’m getting this error:

ReferenceError: document is not defined
    at Object.<anonymous> (/usr/src/app/node_modules/vue-resource/dist/vue-resource.common.js:641:10)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (__vue_ssr_bundle__:3489:18)
    at __webpack_require__ (__vue_ssr_bundle__:21:30)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:11
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
andreiglingeanucommented, Oct 19, 2016

One more idea is to use an HTTP client that’s built to be used both on server and in browser, like axios.

2reactions
afrianjuniorcommented, Oct 19, 2016

i use this for a while

  import Vue from 'vue'
  const inBrowser = typeof window !== 'undefined'

  if (inBrowser) {
    Vue.use(require('vue-resource'))
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-Side Rendering - Vite
Vite provides built-in support for server-side rendering (SSR). The Vite playground contains example SSR setups for Vue 3 and React, which can be...
Read more >
SSR Support for AWS Amplify JavaScript Libraries
Enabling Server-Side Rendering (SSR) support in an Amplify app. When using the Amplify CLI, the aws-exports.js file gets created and updated ...
Read more >
Server-Side Rendering (SSR) - Vue.js
Vite SSR # ... Vite provides built-in support for Vue server-side rendering, but it is intentionally low-level. If you wish to go directly...
Read more >
Using Server-side Rendering (SSR) - Gatsby
Server-side Rendering (SSR) is one of Gatsby's rendering options and allows you to pre-render a page with data that is fetched when a...
Read more >
Server Side Rendering - SAFE Documentation
Server-Side Rendering (SSR) means that some parts of your application code can run on both the server and the client. For React this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found