juancarlospaco / nodejs

Alternative StdLib for Nim for NodeJS/JavaScript targets, hijacks NodeJS StdLib for Nim
https://juancarlospaco.github.io/nodejs
MIT License
205 stars 52 forks source link

JsSyncHttpClient broken #5

Closed tandy-1000 closed 2 years ago

tandy-1000 commented 2 years ago

Console reports JsHttpClient object is null.

Code

Append to bottom of src/nodejs/jssynchttpclient.nim

when isMainModule:
  from std/uri import parseUri, Uri
  let client = newJsHttpClient()
  let url = parseUri("https://google.com")
  let content = client.getContent(url)

src/nodejs/index.html

<script src="jssynchttpclient.js"></script>

How to reproduce

Run nimhttpd and access http://localhost:1337/src/nodejs/index.html, check the browser console.

Console log

Uncaught TypeError: self_436207679 is null
    xmlHttpRequestImpl_436207675 http://localhost:1337/src/nodejs/jssynchttpclient.js:782
    getContent_436207670 http://localhost:1337/src/nodejs/jssynchttpclient.js:798
    <anonymous> http://localhost:1337/src/nodejs/jssynchttpclient.js:929
jssynchttpclient.js:782:5
    xmlHttpRequestImpl_436207675 http://localhost:1337/src/nodejs/jssynchttpclient.js:782
    getContent_436207670 http://localhost:1337/src/nodejs/jssynchttpclient.js:798
    <anonymous> http://localhost:1337/src/nodejs/jssynchttpclient.js:929