Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with window on Universal Rendering #63

Open
Gregcop1 opened this issue Nov 25, 2016 · 3 comments
Open

Error with window on Universal Rendering #63

Gregcop1 opened this issue Nov 25, 2016 · 3 comments

Comments

@Gregcop1
Copy link

I'm trying to use js-data-http with universal rendering but I got an error about window's existence

FAILED: window is not defined ReferenceError: window is not defined
at Object.<anonymous> (xxxxx/node_modules/js-data-http/dist/webpack:/~/axios/lib/adapters/xhr.js:16:1)
at __webpack_require__ (xxxxx/node_modules/js-data-http/dist/js-data-http.js:38:30)
at executor (xxxxx/node_modules/js-data-http/dist/webpack:/~/axios/lib/core/dispatchRequest.js:31:1)
at dispatchRequest (xxxxx/node_modules/js-data-http/dist/webpack:/~/axios/lib/core/dispatchRequest.js:19:1)
at process._tickCallback (internal/process/next_tick.js:103:7)
(node:25772) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): ReferenceError: window is not defined

Regarding this code

	      if (typeof config.adapter === 'function') {
	        // For custom adapter support
	        adapter = config.adapter;
	      } else if (typeof XMLHttpRequest !== 'undefined') {
	        // For browsers use XHR adapter
	        adapter = __webpack_require__(8);
	      } else if (typeof process !== 'undefined') {
	        // For node use HTTP adapter
	        adapter = __webpack_require__(8);
	      }

it require the same function for browser or node but in this function, window object is used without checking its existance.

BTW, thanks a lot for js-data and those adapter...your job is quite impressive

@Gregcop1
Copy link
Author

My Bad it seems to be a problem in axios adapter

@Gregcop1
Copy link
Author

Hi again. I posted the issue on axios repo and I got this answer. Do you know a way to help me please ?
axios/axios#556

@jmdobry
Copy link
Member

jmdobry commented Dec 12, 2016

On the server, you should use the js-data-http-node NPM package instead of js-data-http.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants