node-osmosis
node-osmosis copied to clipboard
debug error after stop instance
osmosis.data(data => {
osmosis.stop()
})
give me error that can't do debug()
on undefined.
the same with pause()
Try this
or this.instance
instead of osmosis
. Obviously you need full function
instead of arrow-function to use this
Was experiencing the same problem, with reference to test/stop.js and the above comment I was able to solve my issue.
https://github.com/rchipka/node-osmosis/blob/fc29b42e9a22945fc8873f44c83b92998cf77a8f/test/stop.js
- Assign osmosis command to a variable
- Call stop on this variable
const instance = osmosis
.post('url', { key: 'value' })
.set({
key: 'selector'
})
.data(data => {
if (condition) {
instance.stop();
}
});