Finish fixing api.js