Update index.js

Res undefined fix