title: How to know the Content-Type of the API response in react native
body: <p>I am new to react native and I am calling GET API using fetch in react-native but sometimes the response <code>Content-Type</code> is <code>text/html</code> and sometimes response <code>Content-Type</code> is <code>application/json</code>.
  I want to check the response <code>Content-Type</code> first before I do response.json().
  I tried using try-catch but it displays a warning on the android screen when try case fail.</p>
  <pre><code>try{
  return response.json();
  }catch(e){
  
  }
  </code></pre>
  <p>I also tried <code>response.ok</code> but it checks for response code instead of a content type.</p>
  <p>What's the correct way to know the <code>response</code> <code>Content-Type</code>?</p>
  <p>UPDATE(Answer):</p>
  <pre><code>if(response.headers.get(&quot;Content-Type&quot;).indexOf(&quot;application/json&quot;)&gt;=0){
    
      //Response is in JSON
  
   }else{
           
      //Response is in text/html
  
   }
  </code></pre>