Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- onWallPost = async () => {
- const {imageData, selectedName} = this.props;
- const token = (VKConnect.default.send("VKWebAppGetAuthToken", {
- "app_id": 7022091,
- "scope": "photos"
- })).then((token) => {
- token = token.data;
- if (token.scope !== 'photos') return;
- let url = (VKConnect.default.send("VKWebAppCallAPIMethod", {
- method: 'photos.getWallUploadServer',
- params: {
- access_token: token.access_token,
- v: '5.95'
- }
- })
- .then(async (url) => {
- const {photo, server, hash} = (await (await fetch('https://toystory-backend.wnm.digital/share/wall', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({
- params,
- server: url.data.response.upload_url,
- name: selectedName,
- file: imageData
- })
- })).json()).resp
- console.log('Code before here is ok')
- const saved = (VKConnect.default.send("VKWebAppCallApiMethod", {
- method: "photos.saveWallPhoto",
- params: {
- access_token: token.access_token,
- v: '5.9',
- //photo, server, hash
- }
- }).then((saved) => {
- console.log('Code after here is not happening anywhere')
- console.log(saved);
- connect.send("VKWebAppShowWallPostBox", {
- "message": "Hello!",
- attachments: `photo${saved[0].owner_id}_${saved[0].id}`
- }).catch((e) => {
- console.error(e);
- });
- }).catch((e) => {
- console.error(e);
- }))
- })
- .catch((e) => {
- console.error(e);
- }))
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement