elasticsearch,google-cloud-functions,request-promise,Firebase,elasticsearch,Google Cloud Functions,Request Promise" /> elasticsearch,google-cloud-functions,request-promise,Firebase,elasticsearch,Google Cloud Functions,Request Promise" />

使用Firebase cloud函数将数据发布到ElasticSearch,无需请求包模块

使用Firebase cloud函数将数据发布到ElasticSearch,无需请求包模块,firebase,elasticsearch,google-cloud-functions,request-promise,Firebase,elasticsearch,Google Cloud Functions,Request Promise,我使用云函数将数据发布到ElasticSearch,我使用请求包将请求发布到ElasticSearch,它工作正常。但是,由于请求包模块现在已被弃用,我不知道现在如何才能做到这一点。以下是我使用的函数: exports.indexCategoriesToElastic = functions.firestore.document('categories/{docID}') .onWrite((change, context) => { let categoryDat

我使用云函数将数据发布到ElasticSearch,我使用请求包将请求发布到ElasticSearch,它工作正常。但是,由于请求包模块现在已被弃用,我不知道现在如何才能做到这一点。以下是我使用的函数:

exports.indexCategoriesToElastic = functions.firestore.document('categories/{docID}')
    .onWrite((change, context) => {
        let categoryData = change.after.data();
        let catId   = context.params.docID;

        let elasticSearchConfig = functions.config().elasticsearch;
        let elasticSearchUrl = elasticSearchConfig.url + 'categories/_doc/' + catId;
        let elasticSearchMethod = categoryData ? 'POST' : 'DELETE';

        let elasticsearchRequest = {
            method: elasticSearchMethod,
            uri: elasticSearchUrl,
            auth: {
                username: elasticSearchConfig.username,
                password: elasticSearchConfig.password,
            },
            body: categoryData,
            json: true
        };
        
        return request(elasticsearchRequest).then(response => {
            console.log('Elasticsearch response', response);
        })
});
我尝试使用Axios和节点获取,但两者都需要指定Url和方法(在Axios中)

谁能告诉我如何在不更改代码的情况下切换到其他软件包

如果需要任何其他细节,请告诉我

谢谢