Update api.js

DB access!!