To query the all channel team and corresponding relation,
Need information through personal information query to the first team, the team is more than one,
Then through the team information query to the channel information,
Parallel send queries to the request of the channel, channel cannot bring back data and query the information associated with the team together,
Is the returned response don't know which team is the id of the query?
To do this?
Example:
For (var I=0; I & lt; Teams. Length; I++)
{
//url contained in the team the id of the
The fetch (url)
. Then ((response)=& gt; {
//here you can get to the url, the response. The url
If (response. Ok)
{
Return the response. Json ();
}
})
. Then ((profile)=& gt; {
Alert (JSON. Stringify (profile));
//here, how to get to the original url??????????? The url contained in the group id of the
});
}
CodePudding user response:
Usage right, you can't be in the for loop directly to below. Then; The fetch returns the result. Then; You can take all the fetch request packed into an array, and then through the array traversal access, such as:
Const teams=[' 399167803 ', '399167750')
Const results=teams. The map (team=& gt; The fetch (' https://bbs.csdn.net/topics/'+ team))
Teams. ForEach ((team, index)=& gt; {
Results [index]. Then (res=& gt; {
The console. The log (' url=& gt; 'and res. Url,'; Team=& gt; 'and the team)
})
})
CodePudding user response:
Also can be so, so, it depends on your so-called team id is the way the get or post to send, the get method, the id should be in the url, and see your code, should be a url only includes an element of teams, so, also can go to counter to check in the teams from the results of the index, because it is both the order of the element set inside and length is the same as
The forEach ((the result, the index)=& gt; {
The result. Then (res=& gt; {
The console. The log (' url=& gt; 'and res. Url,'; Team=& gt; 'teams [index])
})
})