title: Why doesn't if statement check the status of the HTTP request below?
body: <p>After sending an HTTP request I check if the <code>status</code> is 200, then <code>resolve()</code>, but the <code>if</code> statement doesn't seem to work.</p>
  <pre><code>function getMelumat() {
    let promise = new Promise((resolve,reject)=&gt;{
          let xhr = new XMLHttpRequest();
          xhr.open(&quot;GET&quot;,'https://jsonplaceholder.typicode.com/posts');
          xhr.send()
          xhr.onload = ()=&gt;{
              if ( this.status == 200){
                  resolve(this.response)
              }
              else {
                 throw &quot;AN ERROR OCCURED&quot;
              }
            }
          })
  
       return promise
  
      }
           getMelumat().then(data=&gt;{
                  return JSON.parse(data)
              }).then(data=&gt;{
                  console.log(data)
              })
  </code></pre>