Use the api.query method here instead. See https://github.com/FredrikNoren/ungit/blob/master/public/source/api.js for implementation and most other files for how it's used.