Update collectionapi.js

Really handled undefine token.