Any idea on why I keep getting this error
I currently am running a monitor script it and it runs fine for a bit, but as long as it detects a bunch of links come in at the same time, I get this error, whereas, if it detects links at a slower pace and maybe 1-2 links at a single given moment, this error takes longer to appear.
TypeError: res.links.join is not a function
at send (C:UsersbadboysDesktopSHOPIFY SCRIIPTmonitormonitor.js:408:35)
at lib.getStockData (C:UsersbadboysDesktopSHOPIFY SCRIIPTmonitormonitor.js:396:13)
at Request._callback (C:UsersbadboysDesktopSHOPIFY SCRIIPTmonitorlibindex.js:71:20)
at self.callback (C:UsersbadboysDesktopSHOPIFY SCRIIPTmonitornode_modulesrequestrequest.js:186:22)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Request.onRequestError (C:UsersbadboysDesktopSHOPIFY SCRIIPTmonitornode_modulesrequestrequest.js:845:8)
at emitOne (events.js:101:20)
at ClientRequest.emit (events.js:188:7)
at TLSSocket.socketErrorListener (_http_client.js:310:9)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at emitErrorNT (net.js:1278:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
2
Answers
.join()
is a method found on theArray
data type in JavaScript.The error:
res.links.join is not a function
most likely occurs becausejoin
cannot be found as a function onres.links
.It’s most likely that
res.links
returns something other that anarray
at some point even though that is what is expected.Might be with with logging out
res.links
to check this.The solution would be to handle the case where
res.links
is not an array by not attempting ajoin
at that point.I guess you are hitting the API call limit and instead the expected response you are getting an error:
You could solve it by wrapping your monitor function with valvelet.