Module for working with API callings as Promise
import connect from '@vkontakte/vkui-connect'
import connect_promise from 'vk_connect_promise'
connect.subscribe(connect_promise.resolver)
Call VK Connect method
await connect_promise.call("VKWebAppShare", {"link": "https://vk.com/nocell"});
Get access_token for calling VK API methods
const {
data: {
access_token
}
} = await connect_promise.getToken(app_id, ['photos', 'friends']
Make VK API request
const {
data: { response },
} = await connect_promise.api('users.get', {
user_ids: '1',
v: '5.92',
access_token: this.state.token,
})
Set token for call VK API methods via execute-wrapper
const {
data: { access_token },
} = await connect_promise.getToken(app_id, '')
connect_promise.updateToken(access_token)
Make VK API request via execute-wrapper
const data = await connect_promise.execute('users.get', {
user_ids: '1',
v: '5.92',
access_token: this.state.token,
})