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