Update javascript to use promise api.