-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
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
Activity
Gregcop1 commentedon Nov 25, 2016
My Bad it seems to be a problem in axios adapter
Gregcop1 commentedon Nov 27, 2016
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 commentedon Dec 12, 2016
On the server, you should use the
js-data-http-node
NPM package instead ofjs-data-http
.