Update api.js

Fix "Unauthorized" error