surrsoft
10/4/2019 - 8:25 AM

f0842.js

const fetch = require('node-fetch');

const ENDPOINT = 'http://api.cognitiveops.me/graphql';

function sendQuery(payload) {
  return fetch(ENDPOINT, {
    method: 'POST',
    headers: {
      'content-type': 'application/json'
    },
    body: JSON.stringify(payload),
  }).then(res => {
    return res.json();
  });
}

const payload = {
  query: `
    query {
      clients {
        id
      }
    }`,
};

sendQuery(payload)
  .then((res) => {
    console.log('!!!-!!!-!!! res {04.10.2019-9:01}\n', res); //del
  })
  .catch((err) => {
    console.log('!!!-!!!-!!! err {04.10.2019-9:01}\n', err); //del
  });