Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. onWallPost = async () => {
  2.         const {imageData, selectedName} = this.props;
  3.         // Получаем токен с правами photos
  4.         const token = (VKConnect.default.send("VKWebAppGetAuthToken", {
  5.             "app_id": 7022091,
  6.             "scope": "photos"
  7.         })).then((token) => {
  8.             token = token.data;
  9.             // Это условие не выполняется в данном кейсе
  10.             if (token.scope !== 'photos') return;
  11.             let url = (VKConnect.default.send("VKWebAppCallAPIMethod", {
  12.                 method: 'photos.getWallUploadServer',
  13.                 params: {
  14.                     access_token: token.access_token,
  15.                     v: '5.95'
  16.                 }
  17.             })
  18.                 .then(async (url) => {
  19.                     // Эта функция 100% выполняется и возвращает значение
  20.                     const {photo, server, hash} = (await (await fetch('https://toystory-backend.wnm.digital/share/wall', {
  21.                         method: 'POST',
  22.                         headers: {
  23.                             'Content-Type': 'application/json'
  24.                         },
  25.                         body: JSON.stringify({
  26.                             params,
  27.                             server: url.data.response.upload_url,
  28.                             name: selectedName,
  29.                             file: imageData
  30.                         })
  31.                     })).json()).resp
  32.                     // Это выполняется
  33.                     console.log('Code before here is ok')
  34.                     const saved = (VKConnect.default.send("VKWebAppCallApiMethod", {
  35.                         method: "photos.saveWallPhoto",
  36.                         params: {
  37.                             access_token: token.access_token,
  38.                             v: '5.9',
  39.                             //photo, server, hash
  40.                         }
  41.                     }).then((saved) => {
  42.                         // Это не выполняется
  43.                         console.log('Code after here is not happening anywhere')
  44.                         console.log(saved);
  45.                         connect.send("VKWebAppShowWallPostBox", {
  46.                             "message": "Hello!",
  47.                             attachments: `photo${saved[0].owner_id}_${saved[0].id}`
  48.                         }).catch((e) => {
  49.                             // Это не выполняется
  50.                             console.error(e);
  51.                         });
  52.                     }).catch((e) => {
  53.                         // Это не выполняется
  54.                         console.error(e);
  55.                     }))
  56.                 })
  57.                 .catch((e) => {
  58.                     // Это не выполняется
  59.                     console.error(e);
  60.                 }))
  61.         })
  62.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement