function pullData() {

  //Recall who this player is
  fetch('/userID', {
      method: 'POST',
      headers: new Headers({
        'Content-Type': 'application/json'
      }),
      body: JSON.stringify({
        myId
      })
    })
    .catch(err => console.log(err));

  //Check to see if the table has changed
  fetch("/newtable")
    .then((resp) => resp.json()) // Transform the data into json
    .then(function (data) {
      table = data;
      updateTable(data);
    }).catch(err => console.log(err));


  //Always check whose turn is it
  fetch("/getTurn")
    .then((resp) => resp.json()) // Transform the data into json
    .then(function (data) {

      for (item of data.turn) {
        counterInPlay = item.playing;
        counterOpposition = item.opposition;
        kingPlayer = item.king;
        player1ID = parseInt(item.player1);
        player2ID = parseInt(item.player2);
      }
      $('#playersTurn').off().html("Player's turn: " + counterInPlay)
    }).catch(err => console.log(err));

  //Check how many counters there are for each player
  fetch("/getNumberCounters")
    .then((resp) => resp.json()) // Transform the data into json
    .then(function (data) {
      for (item of data.player) {
        countersX = item.xCounters;
        countersY = item.yCounters;
      }
      //Update HTML
      $('#xCounters').off().html(" X's Counters: " + countersX)
      $('#yCounters').off().html(" Y's Counters: " + countersY)
    }).catch(err => console.log(err));

  //Has the game ended
  if (countersX == 0 || countersY == 0) {
    endGame()
  }
  turnOppostionCountersOff();
}
/**
 * @function pullData - called in document ready function every second.
 */
@function pullData - called in document ready function every second.
@function pullData - called in document ready function every second .
function pullData() {
  fetch('/userID', {
      method: 'POST',
      headers: new Headers({
        'Content-Type': 'application/json'
      }),
      body: JSON.stringify({
        myId
      })
    })
    .catch(err => console.log(err));
  fetch("/newtable")
    .then((resp) => resp.json()) 
    .then(function (data) {
      table = data;
      updateTable(data);
    }).catch(err => console.log(err));
  fetch("/getTurn")
    .then((resp) => resp.json()) 
    .then(function (data) {
      for (item of data.turn) {
        counterInPlay = item.playing;
        counterOpposition = item.opposition;
        kingPlayer = item.king;
        player1ID = parseInt(item.player1);
        player2ID = parseInt(item.player2);
      }
      $('#playersTurn').off().html("Player's turn: " + counterInPlay)
    }).catch(err => console.log(err));
  fetch("/getNumberCounters")
    .then((resp) => resp.json()) 
    .then(function (data) {
      for (item of data.player) {
        countersX = item.xCounters;
        countersY = item.yCounters;
      }
      $('#xCounters').off().html(" X's Counters: " + countersX)
      $('#yCounters').off().html(" Y's Counters: " + countersY)
    }).catch(err => console.log(err));
  if (countersX == 0 || countersY == 0) {
    endGame()
  }
  turnOppostionCountersOff();
}
function pullData ( ) { fetch ( '/userID' , { method : 'POST' , headers : new Headers ( { 'Content-Type' : 'application/json' } ) , body : JSON . stringify ( { myId } ) } ) . catch ( err => console . log ( err ) ) ; fetch ( "/newtable" ) . then ( ( resp ) => resp . json ( ) ) . then ( function ( data ) { table = data ; updateTable ( data ) ; } ) . catch ( err => console . log ( err ) ) ; fetch ( "/getTurn" ) . then ( ( resp ) => resp . json ( ) ) . then ( function ( data ) { for ( item of data . turn ) { counterInPlay = item . playing ; counterOpposition = item . opposition ; kingPlayer = item . king ; player1ID = parseInt ( item . player1 ) ; player2ID = parseInt ( item . player2 ) ; } $ ( '#playersTurn' ) . off ( ) . html ( "Player's turn: " + counterInPlay ) } ) . catch ( err => console . log ( err ) ) ; fetch ( "/getNumberCounters" ) . then ( ( resp ) => resp . json ( ) ) . then ( function ( data ) { for ( item of data . player ) { countersX = item . xCounters ; countersY = item . yCounters ; } $ ( '#xCounters' ) . off ( ) . html ( " X's Counters: " + countersX ) $ ( '#yCounters' ) . off ( ) . html ( " Y's Counters: " + countersY ) } ) . catch ( err => console . log ( err ) ) ; if ( countersX == 0 || countersY == 0 ) { endGame ( ) } turnOppostionCountersOff ( ) ; }
@function pullData - called in document ready function every second.
@function pullData - called in document ready function every second .
//Recall who this player is //Check to see if the table has changed // Transform the data into json //Always check whose turn is it // Transform the data into json //Check how many counters there are for each player // Transform the data into json //Update HTML //Has the game ended