通过appbase-js显示结果

时间:2019-03-18 20:16:59

标签: node.js reactivesearch

我一直在使用ReactiveSearch库来使用其React组件轻松地构建搜索UI(伟大的lib!)。

我已经开始使用他们的appbase-js(Nodejs的库),但是我很难让搜索结果显示出来,并且不确定我在做什么错。

我的快速应用路线如下:

router.get('/appbase', apiController.getAppbase);

这是我的路线处理程序

exports.getAppbase = (req, res, next) => {

  // create an Appbase instance
  const appbaseReadRef = new Appbase({
    url: 'https://scalr.api.appbaseio',
    app: 'housing-demo',
    credentials: process.env.HOUSING_DEMO_READ
  });

  // Fetch All https://docs.appbase.io/interactive/javascript.html#fetch-all
  appbaseReadRef.search({
    type: 'listing',
    body: {
      query: {
        match_all: {}
      }
    }
  }).then(response => {
    // Logging hits which contain all the data matched by query
    console.log("Success: ", JSON.stringify(response, null, "\t"));
  }).catch(error => {
    console.log("Error: ", error)
  });

  const results = {
    response: name.response,
    response: room_type.response,
    response: property_type.response,
    response: price.response,
    response: has_availability.response,
    response: accommodates.response,
    response: bedrooms.response,
    response: bathrooms.response,
    response: beds.response,
    response: bed_type.response,
    response: host_image.response,
    response: host_name.response,
    response: image.response,
    response: listing_url.response,
    response: location.response,
    response: date_from.response,
    response: date_to.response
  };

  res.render('api/appbase', {
    title: 'Appbase JS API',
    results
  });
};

这是我的哈巴狗视图:

.card.w-100
  .card-body
    .col-sm
      .card
         .card-body
         h4.card-title results.name
         h6.card-subtitle.mb-2.text-muted TEXT
         p.card-text TEXT
         h6.card-subtitle.mb-2.text-muted TEXT

我无法显示results.name(图一开始,我就可以正确地使用其他名称)

0 个答案:

没有答案