fix errors in api.js