所以我有 2 个端点,我正在向第一个端点发出“发布”请求,在响应中我应该得到我在第二个请求端点 url 中使用的某种 id。所以我想延迟或什么,直到我得到第一个请求的响应。
req = () => {
fetch('url', {
method: 'POST',
headers: {
'Authorization': bearer,
'Content-Type': 'application/json',
},
body:
})
.then(response => response.json())
.then(json => {
})
fetch(`url with the id I get from the first request`, {
method: 'GET',
headers: {
'Authorization': bearer,
'Content-Type': 'application/json',
}
})
.then(response => response.json())
.then(json => {
})
}