title: coinmarketcap api integration - 401 error - JavaScript
body: <p>I am trying to integrate <a href="https://coinmarketcap.com/api/documentation/v1/#section/Errors-and-Rate-Limits" rel="nofollow noreferrer">coinmarketcap api</a> but cannot really get the data. I registered, got the API key, and wrote the following method to fetch the data: </p>
  
  <pre><code>let getPostsList = async () =&gt; {
       const options = {
          method: 'GET',
          headers: {
              'X-CMC_PRO_API_KEY': 'api-key-goes-here'
          },
           mode: 'no-cors'
      };
  
          try {
          const response = await fetch(`https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest`, options);
          const json = await response.body;
          // console.log(json)
          return json
      } catch (err) {
          console.log('Error: ', err)
      }
  };
  </code></pre>
  
  <p>All I get is 401 error, like this:</p>
  
  <blockquote>
    <p>GET <a href="https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest" rel="nofollow noreferrer">https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest</a>
    401</p>
  </blockquote>
  
  <p>Any suggestions what I should fix? Docs says that 401 is likely connected to API key, but they say to provide it in the headers like the above...</p>