Извините, что задал этот вопрос еще раз, но я попробовал все решения и продолжаю получать эту ошибку. Я подключаю elastic search
к своему проекту Android. Я застрял в этом, я попробовал все.
Снимок ошибки:
![This is the snapshot of the error](https://i.stack.imgur.com/PUGCz.png)
Это мой index.js
файл. Я внес все изменения, но все еще получаю сообщение об ошибке.
const functions = require('firebase-functions');
const request = require('request-promise')
exports.indexPostsToElastic = functions.database.ref('/posts/{post_id}')
.onWrite(( change,context) => {
let postData = change.after.val();
let post_id = context.params.post_id;
console.log('Indexing post:', postData);
let elasticSearchConfig = functions.config().elasticsearch;
let elasticSearchUrl = elasticSearchConfig.url + 'posts/post/' + post_id;
let elasticSearchMethod = postData ? 'POST' : 'DELETE';
let elasticSearchRequest = {
method: elasticSearchMethod,
url: elasticSearchUrl,
auth:{
username: elasticSearchConfig.username,
password: elasticSearchConfig.password,
},
body: postData,
json: true
};
return request(elasticSearchRequest).then(response => {
console.log("ElasticSearch response", response);
});
});
Это код моего файла package.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"firebase-admin": "~7.0.0",
"firebase-functions": "^2.2.0",
"request": "^2.88.0",
"request-promise": "^4.2.4"
},
"private": true
}
Это снимок моей базы данных
![enter image description here](https://i.stack.imgur.com/gDitA.png)