Prevent nodejs from responding to GET twice
I had a really huge api call loop in one of my get requests in my routes file in an attempt to populate the local database with selective json results.
However, when I was running it, I noticed that the GET request was responded to twice and it caused my code to run twice, causing an overlap in the resulting dataset.
After searching I found out that it was because nodejs was attempting to GET the favicon for the page.
Because I didn't have a favicon, all I added was:
next();
at the start of the router function and the second GET response stopped occurring afterwards.
Written by yaojie
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Nodejs
Authors
Related Tags
#nodejs
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#