Last Updated: February 25, 2016
·
2.386K
· causztic

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.