Read streaming data using web api and save to mongodb


i am using request package of npm.

and this code on server side


it process the get api and prints data every 2 second on console.

but i need to save that data in mongo db.

but in .pipe() method if i write any function to do any thing rather then process.stdout it gives error.

what should i do ?