loading
open in
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const Appbase = require("appbase-js");

// Create appbase instance to use methods
const appbaseRef = Appbase({
  url: "https://scalr.api.appbase.io",
  app: "housing-demo",
  credentials: "YnCgVwozV:e9ec5cb0-58d8-4bb0-badc-acaf726661f1"
});

// Search for matching documents in a type.
// Querying all data with match_all
appbaseRef.search({
  type: "listing",
  body: {
    query: {
      geo_distance: {
        distance: "5mi",
        location: {
          lat: 47.59,
          lon: -122.29
        }
      }
    }
  }
}).then(response => {
  // Logging hits which contains all the data matched by query
  console.log("Success: ", JSON.stringify(response.hits, null, '\t'));
}).catch(error => {
  console.log("Error: ", error);
});
node v9.7.1 linux/amd64