我正在尝试构建Firebase云功能,为用户生成仪器部件。应该从应用程序中调用云函数生成零件,然后将生成的零件返回给应用程序进行记录。
这是我的App功能:
public void addInstrumentToMix() {
//Allow the user to select an instrument
//once the user has seleced there instrument generate that instruments part
//call firebase cloud function to generate instrument part and return to it to app
}
这是我的云功能:
exports.generateGuitarPart = functions.https.onRequest((request, response) => {
//Use math to generate notes per instrument, eventually would like to generate these instrument peices through machine learning
var notes = {"21","45"} //sample value
return notes;
});
答案 0 :(得分:0)
您需要从您的函数向客户端发送响应。从函数返回值实际上不会发回任何内容。将响应发送回客户端的最小函数位于您运行firebase init
时Firebase CLI为您创建的index.js中。
exports.generateGuitarPart = functions.https.onRequest((request, response) => {
//Use math to generate notes per instrument, eventually would like to generate these instrument peices through machine learning
response.send({"21","45"})
})
请consult the documentation更好地了解HTTPS类型功能的工作原理。