Update collectionapi.js

Handled undefined token.