admin管理员组文章数量:1123692
In frontend I am using React Js and in Backend I am using Node Js.
So in frontend I call an API <api_base_url>/v1/translate
and pass down request params like { translate_ids: [1,2,3,4,5, ... 100000] }
and in Node JS I receive the params and translate like,
exports.translateSelectedString = async (req, res) => {
try {
const { translate_ids } = req.body;
const records = await models.translate.findAll({ attributes: ["str_value"], where: { id: translate_ids } });
const translations = await Promise.all(records.map(async (record) => {
await getTranslationTextFromTranslateApi(record.str_value, 'eng', 'fra');
}));
return res.status(200).json({ status: "success", data: translations });
}
catch (exception) {
return res.status(500).json({ status: "failure", message: exception.message });
}
};
本文标签: javascriptHow to handle calling external API with large data in NodejsStack Overflow
版权声明:本文标题:javascript - How to handle calling external API with large data in Nodejs? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736590666a1945071.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论