I have a simple javascript function that creates an XMLHttpRequest , runs it (synchronously to make things as simple as possible) and returns an array that is the result.
exports.loadBinFile = function() { ... }
I have that script in a js file, x.js, and I have a matching PureScript file x.purs, and in it:
foreign import loadBinFile :: forall e. Eff (fileLoad :: FILELOAD | e) (Array Int)
All is fine and well regarding that, but I'm using XMLHttpRequest which is a browser object, and when trying to run pulp run, I'm getting an error that XMLHttpRequest is undefined.
I've tried installing an npm package called xmlhttprequest which contains said object, also tried a similar bower package, but both fail.
I'm relatively new to javascript, and I assume the way I'm trying to make things wrong, is outright wrong. What would be the correct way of approaching this?
I figure I can fix this by putting the script inside an .html file, but I want to do this correctly, i.e. having matching .purs and .js files, and letting pulp do it's job.
How should I go about doing this?
Thanks!