baidu / baidu/amis

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

Open
#6,489 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
18.9k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

非常抱歉截图上传不上来。。
这里是json
```json
api: {
method: 'post',
url: '/admin/api/common/listAndCount',
requestAdaptor: requestAdaptorNftList,
}
```
js
```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 并没有按照写的配置进行返回

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the requestAdaptorNftList entry point shown in the issue and inspect the requestAdaptor contract and its caller. Reproduce the nested request case, then verify whether the adaptor's asynchronous result is consumed before the outer request is sent. Done means the supported behavior and required return shape are documented or covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.