0
私は新しいユーザーを追加してユーザーを順番に編集する2つのURLを持っています。最初の要求の出力を2番目の要求に入力として渡すにはどうすればよいですか。以下は1つのAPI呼び出しの応答を別のAPIに渡す
http://localhost:3010/postuser
{"name":"xyz"}
// response will be unique id =>001
http://localhost:3010/putuser
{"id":001} //Get the output of first request as input here
一つの関数からのデータは次の関数に渡すことができるように私のコード
function httpGet(options, callback) {
request(options,
function (err, res, body) {
callback(err, body);
}
);
}
const urls = [
{
url: 'http://localhost:3010/postuser',
method: 'POST'
},
{
url: 'http://localhost:3010/putuser',
method: 'PUT'
}
];
async.mapSeries(urls, httpGet, function (err, res) {
if (err) return console.log(err);
console.log(res);
});
回答を知っている人は誰でも投票してください – user4324324