Fire base返回为调用app生成的值

时间:2018-01-25 23:14:47

标签: firebase google-cloud-functions

我正在尝试构建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;

});

1 个答案:

答案 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类型功能的工作原理。