Update index.js

moved console.log position, previous example did not produce correct response