Move js calling api out to an independent file.