Standalone Javascript example

Plain javascript (node.js)

Plain node.js/javascript without gillie-api library. This example uses axios library for REST calls. You can use any library for this purpose.

let axios = require("axios");
// Crypto library for calculating sha256 hash code
let crypto = require('crypto');
let publicKey = "...public key here...";
let privateKey = "..private key here...";

example();

async function example() {
  // Salt and hash
  let apisalt = Math.round((new Date().getTime() / 1000)).toString();
  let apihash = crypto.createHash('sha256')
    .update(privateKey + publicKey + apisalt)
    .digest('hex');

  let request = {
    url: "https://gillie.io/api/customers",
    params: { apihash: apihash, apisalt: apisalt, apikey: publicKey },
    method: 'get'
  };

  request.headers = {
    'Content-Type': 'application/json;'
  }
  try {
    let result = await axios(request);
    console.log(result.data);
  } catch (err) {
    console.log(err);
  }
}