title: Turning a result into a const
body: <p>Admitting I'm a very newbie dev</p>
  <p>I'm writing my first app not following/adding into existing code.</p>
  <p>I'd like to set a const from an api, the field is totalGames</p>
  <p>Url for reference <a href="http://statsapi.mlb.com/api/v1/schedule/games/?sportId=1" rel="nofollow noreferrer">http://statsapi.mlb.com/api/v1/schedule/games/?sportId=1</a></p>
  <p>Field is the 4th line</p>
  <p>In nodejs I can get it to console the result I want out with this</p>
  <pre><code>const request = require('postman-request')
  const MLBStatsAPI = require('mlb-stats-api')
  const { response } = require('express')
  const mlbStats = new MLBStatsAPI()
  
  const url = 'http://statsapi.mlb.com/api/v1/schedule/games/?sportId=1'
  
  request ({url:url}, (error,response) =&gt; {
      const todaygames = JSON.parse(response.body)
      console.log(todaygames.totalGames)
  })
  </code></pre>
  <p>I would like to keep that result (in today's example: 14) as a value I can work from.</p>
  <p>I would think you should be able to change</p>
  <p>const todaygames = JSON.parse(response.body)</p>
  <p>to</p>
  <p>const todaygames = JSON.parse(response.body.totalGames)</p>
  <p>console.log(todaygames)</p>
  <p>and get the result I want, but it comes back with</p>
  <pre><code>  undefined:1
      undefined
  ^
  
      SyntaxError: Unexpected token u in JSON at position 0
      at JSON.parse (&lt;anonymous&gt;)
      at Request._callback (/Users/jamescpower/BaseballApp/src/app.js:30:29)
  </code></pre>