How to make a fetch() POST request to wordpress rest api?

'X-WP-Nonce' : Ajax.nonce Was missing that’s why it was giving the error

  fetch('https://mywebsite.online/wp-json/wp/v2/code', {
      method: 'POST',
      credentials: 'same-origin',
      headers: new Headers({
        'Content-Type': 'application/json;charset=UTF-8',
        'X-WP-Nonce' : Ajax.nonce
      }),
      body: JSON.stringify(OurPostData),
    }).then(response => {
      console.log(response);
      return response.json();
    });

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)