Couldn't get it into one post: the output of the trace(req) call is:
#354[r2,l1] Object { #355[r1,l2] Name String [2 blocks] "__proto__" #368[r1,l1] ... #369[r1,l2] Name String [1 blocks] "type"= int 1 #368[r1,l2] Name String [2 blocks] "#onconnect" #482[r1,l1] Function { #481[r1,l2] Name Param "resp" undefined #129[r1,l2] Name String [1 blocks] "ÿcod" #274[r1,l1] FlatString [29 blocks] "resp.on(\"data\",function(d){if(d!==\"OK\")console.log(\"Got unexpected response:\",d)});resp.on(\"close\",function(gotErr){if(!gotErr&&resp.statusCode!==\"200\")console.log(\"Got HTTP code\",resp.statusCode);if(gotErr||resp.statusCode!==\"200\")errCnt++;else okCnt++});resp.on(\"error\",function(err){console.log(\"HTTP response error: \",err.message)})" #131[r1,l2] Name String [1 blocks] "ÿsco" #526[r3,l3] Function { #525[r1,l2] Name Param "temp" #374[r2,l1] Double 12.54 #524[r1,l3] Name String [2 blocks] "return" undefined #522[r1,l2] Name String [1 blocks] "q" #517[r2,l1] ... #511[r1,l2] Name String [1 blocks] "req" #354[r2,l2] ... } } #303[r1,l2] Name String [1 blocks] "res" #135[r1,l1] Object { #138[r1,l2] Name String [2 blocks] "__proto__" #354[r2,l2] ... } #304[r1,l2] Name String [1 blocks] "opt" #517[r2,l1] Object { #514[r1,l2] Name String [2 blocks] "protocol" #513[r1,l1] String [1 blocks] "http:" #507[r1,l2] Name String [2 blocks] "method" #521[r1,l1] String [1 blocks] "POST" #503[r1,l2] Name String [1 blocks] "host" #505[r1,l1] String [2 blocks] "h.voneicken.com" #500[r1,l2] Name String [1 blocks] "path" #502[r1,l1] String [2 blocks] "/temp?temp=12.54" #498[r1,l2] Name String [2 blocks] "pathname" #499[r1,l1] String [1 blocks] "/temp" #493[r1,l2] Name String [2 blocks] "search" #495[r1,l1] String [2 blocks] "?temp=12.54" #490[r1,l2] Name String [1 blocks] "port" #491[r1,l1] Integer 4567 #487[r1,l2] Name String [2 blocks] "query" #489[r1,l1] String [2 blocks] "temp=12.54" #518[r1,l2] Name String [2 blocks] "headers" #519[r1,l1] Object { #512[r1,l2] Name String [3 blocks] "Content-Length"= int 0 } } #315[r1,l2] Name String [2 blocks] "#onerror" #305[r1,l1] Function { #306[r1,l2] Name Param "err" undefined #313[r1,l2] Name String [1 blocks] "ÿcod" #307[r1,l1] FlatString [6 blocks] "console.log(\"HTTP request error: \",err.message);errCnt++" #314[r1,l2] Name String [1 blocks] "ÿsco" #526[r3,l3] Function { #525[r1,l2] Name Param "temp" #374[r2,l1] Double 12.54 #524[r1,l3] Name String [2 blocks] "return" undefined #522[r1,l2] Name String [1 blocks] "q" #517[r2,l1] ... #511[r1,l2] Name String [1 blocks] "req" #354[r2,l2] ... } } #326[r1,l2] Name String [2 blocks] "#onclose" #318[r1,l1] Function { #319[r1,l2] Name Param "gotErr" undefined #324[r1,l2] Name String [1 blocks] "ÿcod" #321[r1,l1] FlatString [3 blocks] "console.log(\"HTTP done\")" #325[r1,l2] Name String [1 blocks] "ÿsco" #526[r3,l3] Function { #525[r1,l2] Name Param "temp" #374[r2,l1] Double 12.54 #524[r1,l3] Name String [2 blocks] "return" undefined #522[r1,l2] Name String [1 blocks] "q" #517[r2,l1] ... #511[r1,l2] Name String [1 blocks] "req" #354[r2,l2] ... } } }
What looks a little suspicious to me is the #355[r1,l2] Name String [2 blocks] "__proto__" #368[r1,l1] ... part. On a req object that works it's:
#355[r1,l2] Name String [2 blocks] "__proto__" #368[r1,l1] ...
>trace(req) #97[r2,l1] Object { #98[r1,l2] Name String [2 blocks] "__proto__" #93[r2,l1] Object { #94[r1,l2] Name String [2 blocks] "constructor" #89[r2,l1] NativeFunction 0x40221210 (1) { #90[r1,l2] Name String [2 blocks] "prototype" #93[r2,l2] ... } } #102[r1,l2] Name String [1 blocks] "type"= int 1 ...
@tve started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Couldn't get it into one post: the output of the trace(req) call is:
What looks a little suspicious to me is the
#355[r1,l2] Name String [2 blocks] "__proto__" #368[r1,l1] ...
part. On a req object that works it's: