How to use w3c-xmlhttprequest - 4 common examples

To help you get started, we’ve selected a few w3c-xmlhttprequest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mvlabs / isomorphic-mithril / server.js View on Github external
// SERVER SIDE APP
// ==============================================================

'use strict';
require('mithril/test-utils/browserMock')(global);
global.window.XMLHttpRequest = require('w3c-xmlhttprequest').XMLHttpRequest;

const server = require('./app/server');
const port = process.env.PORT || 3000;


server.listen(port, () => {
    console.log('Listening on localhost:' + port + '...');
});
github smartscenes / sstk / ssc / stk-ssc.js View on Github external
_.defaults(sscConfig, {base_url: process.env.NODE_BASE_URL, assets_url: 'file://' + __dirname + '/../server/static'});
}
global.window.globals = sscConfig;

console.log('Configuration', sscConfig);

var STK = require('sstk-core');
// Indicate that we are not on the browser
STK.Constants.isBrowser = false;

//console.log('baseUrl is ' + STK.Constants.baseUrl);
//console.log('assetsDir is ' + STK.Constants.assetsDir);
// Who uses the XMLHttpRequest?  ColladaLoader and _.getJSON
if (STK.Constants.baseUrl.startsWith('http:') || STK.Constants.baseUrl.startsWith('https:') ) {
  // NOTE: Don't support file://
  global.XMLHttpRequest = require('w3c-xmlhttprequest').XMLHttpRequest;
} else {
  // NOTE: Don't post response in event!!!
  global.XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
}
STK.ImageUtil.getPixelsSync = deasync(getPixels);

var AssetGroups = STK.assets.AssetGroups;
var AssetsDb = STK.assets.AssetsDb;

var cachedFileLoader = new STK.assets.CachedAssetLoader({
  assetCacheSize: sscConfig.fileCache.size,
  loadFn: function (loadOpts, callback) {
    //console.log('load ' + loadOpts.url + ', ' + this.responseType);
    fs.readAsync(loadOpts.url, loadOpts.encoding || 'utf8', callback);
  }
});
github StephanHoyer / mithril-isomorphic-example / server.js View on Github external
'use strict'
require('mithril/test-utils/browserMock')(global)
global.window.XMLHttpRequest = require('w3c-xmlhttprequest').XMLHttpRequest

var express = require('express')
var bodyParser = require('body-parser')
var web = require('./server/web')
var rest = require('./server/rest')
var compression = require('compression')
var browserify = require('browserify-middleware')

var app = express()

app.use(
  bodyParser.urlencoded({
    extended: true,
  })
)
app.use(bodyParser.raw())
github mvlabs / isomorphic-mithril / src / server-side-render / browser-mock.js View on Github external
require('mithril/test-utils/browserMock')(global)
global.window.XMLHttpRequest = require('w3c-xmlhttprequest').XMLHttpRequest

w3c-xmlhttprequest

Server-side XMLHttpRequest.

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular w3c-xmlhttprequest functions