amis 请问可以在requestAdaptor 发送一个异步请求 然后用这个接口的数据做本身请求(本身的请求是get)的入参 但是并没有按照ruturn出去的结果进行接口调用

kzipqqlq  于 22天前  发布在  其他
关注(0)|答案(1)|浏览(19)

非常抱歉截图上传不上来。。
这里是json

api: {
        method: 'post',
        url: '/admin/api/common/listAndCount',
        requestAdaptor: requestAdaptorNftList,
      }

js

function requestAdaptorNftList(api) {
  const baseApi = '/admin/api/common/listAndCount?';
  const baseParams = {
    sortField: 'createdTime',
    sortRule: 'DESC',
    page: api.body.page,
    limit: api.body.limit,
  };
  api.method = 'get';
  const key = api.body.id;
  delete api.body.id;
  if (key?.length === 11) {
    request
      .request({
        method: 'get',
        url: `${baseApi}${QueryString.stringify(
baseParams,
)}&modelName=AccountModel&phone=${key}`,
      })
      .then((result) => {
        api.method = 'get';
        api.url = `${baseApi}${baseParams}`;
        const accountId =
          result.data?.data?.list?.length > 0
            ? result?.data?.data?.list[0].accountId
            : null;
        if (accountId) {
          const body = _.pickBy({
            modelName: 'NftModel',
            accountId: accountId,
            cid: api.body.cid,
          });
          api.url = `${baseApi}${QueryString.stringify(
baseParams,
)}&${QueryString.stringify(body)}`;
          api.method = 'get';
          return {
            ...api,
          };
        } else {
          notification.error({
            type: 'error',
            message: '当前手机号没有注册用户',
          });
          return {
            
          };
        }
      });
  } else {
    api.method = 'get';
    api.body.nftRuleId = key;
    const params = QueryString.stringify(api.body);
    api.url = `${baseApi}${params}`;
    return api;
  }
}

在这里return的api 并没有按照写的配置进行返回

1bqhqjot

1bqhqjot1#

是不是可以外面套一个service组件先请求然后 内部组件加个sendOn等外部service组件返回的某个值存在了再去请求呢?

相关问题