如何对 MercadoLivre 请求进行隐形回调?

How make invisible callback on MercadoLivre request?

m use the mercadolivres API 并且它需要一个请求 return 一个带有令牌的回调但是... 我需要这个过程是不可见的,只有 return 个令牌。

我用我的后端调用函数,回调是:

import React, { Component } from 'react';
import {getToken} from '../../../auth';
import axios from 'axios';
import Swal from 'sweetalert2';

class CallBack extends Component {

  constructor(props) {
    super(props);
    const token = window.location.href.split('?')[1].split('=')[1].split('&')[0];
    this.state = {
      token: token,
      message: '',
      status: '',
      executed: false,
      doIt: 0
    };
  }
  render(){
    const token = this.state.token;

    return (
        !this.state.executed ? (

            axios.post(process.env.REACT_APP_API_URL + `/accounts/from-mercado-livre`,
                {"code": token,},
                {headers: {"Authorization": 'Bearer ' + getToken()}},
            ).then(res => {

              this.setState(
                  {
                    executed: true,
                    doIt: 2
                  }
              )

              if (res.data.status === 'success') {
                Swal.fire({
                  html: '<p>' + res.data.message + '</p>', type: 'success', showConfirmButton: true,
                  onClose: () => {
                    this.props.history.push('/listacontas');
                    window.location.reload();
                  }
                });
              } else {
                Swal.fire({
                  html: '<p>' + res.data.message + '</p>', type: 'error', showConfirmButton: true,
                  onClose: () => {
                    this.props.history.push('/listacontas');
                    window.location.reload();
                  }
                });
              }
            }).catch(error => {
              console.log('rejected');
              console.log(error.response);


              if (error.response !== undefined) {
                Swal.fire({
                  html: '<p>' + error.response.data.message + '</p>',
                  type: 'error',
                  showConfirmButton: false,
                  showCancelButton: true,
                  cancelButtonText: 'Fechar',
                  onClose: () => {
                    this.props.history.push('/listacontas');
                    window.location.reload();
                  }
                });
              } else {
                this.props.history.push('/listacontas');
                window.location.reload();
              }
            })

        ) : (
            console.log('None')
        )
    ) 
  }
}

export default CallBack;

我为我的后端发送了一个用户令牌,它的 return 另一个带有回调信息的令牌。

我希望让用户看不到所有进程,只显示一条成功消息。

不可能,因为事件是在浏览器之外开始的。

我制作了一个异步方法,它使用后端接收状态并解决了问题。但是,我不能在这里分享它,因为它包含私人信息。