Skip to content

Error with window on Universal Rendering #63

@Gregcop1

Description

@Gregcop1

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

Gregcop1 commented on Nov 25, 2016

@Gregcop1
Author

My Bad it seems to be a problem in axios adapter

Gregcop1

Gregcop1 commented on Nov 27, 2016

@Gregcop1
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

jmdobry commented on Dec 12, 2016

@jmdobry
Member

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jmdobry@Gregcop1

        Issue actions

          Error with window on Universal Rendering · Issue #63 · js-data/js-data-http