diff --git a/sdk.js b/sdk.js index 1d0be59..37feb9b 100644 --- a/sdk.js +++ b/sdk.js @@ -541,3 +541,26 @@ VK.prototype._parseSessionData = function(data) { return this.sortObjectByKey(parsedData); }; + + + +/** + * Promise API method + * @param {string} _method + * @param {mixed} _params + * @param {mixed} _response + * @returns {Promise} + * + * @see https://vk.com/pages?oid=-17680044&p=Application_Interaction_with_API + */ +VK.prototype.promise = function(_method, _requestParams) { + return new Promise((resolve,reject)=>{ + this.request(_method,_params,(res)=>{ + if(res.error) { + reject(res.error) + } else { + resolve(res); + } + }) + }) +}; \ No newline at end of file