title: NPM POST fetch returns 405 after successful call
body: <p>I have seen some similar issues posted here, but most are in different languages. I have inherited a npm project that makes a Post fetch request to a google app script web app. Before inheriting this project I had no experience with npm. The web app executes successfully but the project is receiving a 405 error.</p>
  <pre><code>Fetch res:  Body {
    url: 'https://script.googleusercontent.com/macros/echo?...',
    status: 405,
    statusText: 'Method Not Allowed',
    headers:
     Headers {
       _headers:
        { 'cache-control': [Array],
          pragma: [Array],
          expires: [Array],
          date: [Array],
          'content-type': [Array],
          'content-encoding': [Array],
          'referrer-policy': [Array],
          allow: [Array],
          'x-content-type-options': [Array],
          'x-xss-protection': [Array],
          server: [Array],
          'alt-svc': [Array],
          connection: [Array],
          'transfer-encoding': [Array] } },
    ok: false,
    body:
     Gunzip {
       _readableState:
        ReadableState {
          objectMode: false,
          highWaterMark: 16384,
          buffer: [BufferList],
          length: 0,
          pipes: null,
          pipesCount: 0,
          flowing: null,
          ended: false,
          endEmitted: false,
          reading: false,
          sync: false,
          needReadable: true,
          emittedReadable: false,
          readableListening: false,
          resumeScheduled: false,
          destroyed: false,
          defaultEncoding: 'utf8',
          awaitDrain: 0,
          readingMore: false,
          decoder: null,
          encoding: null },
       readable: true,
       domain: null,
       _events:
        { end: [Array],
          prefinish: [Function: prefinish],
          unpipe: [Function: onunpipe],
          drain: [Function],
          error: [Function: onerror],
          close: [Function],
          finish: [Function] },
       _eventsCount: 7,
       _maxListeners: undefined,
       _writableState:
        WritableState {
          objectMode: false,
          highWaterMark: 16384,
          finalCalled: false,
          needDrain: false,
          ending: false,
          ended: false,
          finished: false,
          destroyed: false,
          decodeStrings: true,
          defaultEncoding: 'utf8',
          length: 0,
          writing: false,
          corked: 0,
          sync: true,
          bufferProcessing: false,
          onwrite: [Function: bound onwrite],
          writecb: null,
          writelen: 0,
          bufferedRequest: null,
          lastBufferedRequest: null,
          pendingcb: 0,
          prefinished: false,
          errorEmitted: false,
          bufferedRequestCount: 0,
          corkedRequestsFree: [Object] },
       writable: true,
       allowHalfOpen: true,
       _transformState:
        { afterTransform: [Function: bound afterTransform],
          needTransform: false,
          transforming: false,
          writecb: null,
          writechunk: null,
          writeencoding: null },
       bytesRead: 0,
       _handle: Zlib { jsref: [Circular], onerror: [Function: zlibOnError] },
       _hadError: false,
       _writeState: Uint32Array [ 0, 0 ],
       _outBuffer: &lt;Buffer b0 c3 05 6c 9a 7f 00 00 b0 c3 05 6c 9a 7f 00 00 30 5b 7f 03 00 00 00 00 30 5b 7f 03 00 00 00 00 07 00 00 00 4e 6f 74 20 68 ce 60 03 00 00 00 00 90 ce ... &gt;,
       _outOffset: 0,
       _level: -1,
       _strategy: 0,
       _chunkSize: 16384,
       _flushFlag: 0,
       _scheduledFlushFlag: 0,
       _origFlushFlag: 0,
       _finishFlushFlag: 4,
       _info: undefined },
    bodyUsed: false,
    size: 0,
    timeout: 0,
    _raw: [],
    _abort: false }
  (node:531) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'json' of undefined
      at fetch.then.then.res (/mnt/c/Users/John Norry/Desktop/jidoka/server/routes/parts.js:72:28)
      at &lt;anonymous&gt;
      at process._tickCallback (internal/process/next_tick.js:160:7)
  (node:531) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
  (node:531) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  </code></pre>
  <p>When I test in Postman I get a proper JSON response that I am expecting.</p>
  <pre><code>{
      &quot;status&quot;: 201,
      &quot;partid&quot;: &quot;211040&quot;
  }
  </code></pre>
  <p>Here is the npm fetch call</p>
  <pre><code>module.exports = db =&gt; {
    partRoutes.post('/create', (req, res) =&gt; {
  
      sessionCheck(req.session.email, db)
        .then(authorized =&gt; {
          if (!authorized) return res.sendStatus(403)
  
          var request_data = {
              url: createUpdateScript,
              method: 'POST',
          };          
          var auth = oauth.toHeader(oauth.authorize(request_data, token)).Authorization
          
          let options = {
            method: 'post',
            body: JSON.stringify(req.body),
            headers: {
              'Authorization': auth,//netsuiteCreds,
              'Content-Type': 'application/json',
              'muteHttpExceptions':false
            }
          }
  
          fetch(createUpdateScript, options)
            .then(res =&gt; console.log(&quot;Fetch res: &quot;, res))
            .then(res =&gt; res.json())
            .then(data =&gt; res.status(201).send(data))
        })
        .catch(err =&gt; {
          console.error(&quot;Create Route Err: &quot;, err) 
          res.sendStatus(500)
        })
    })
  </code></pre>