node-samples icon indicating copy to clipboard operation
node-samples copied to clipboard

Upgrade samples to v40 and use new requestBody key

Open codeekage opened this issue 6 years ago • 3 comments

Can I make a quick contribution to improving the docs? requestBody object to replace responses like so:

Pass

const req = {
  requestBody: {
          properties: {
            title : sheetTitle
          }
        },
        auth
}
 sheet.spreadsheets.create(req, callback)

//Using Promises

const creatSheet = await  sheet.spreadsheets.create(req)

Fails

const res = {
  resource: {
          properties: {
            title : sheetTitle
          }
        },
        auth
}
 sheet.spreadsheets.create(res, callback)

// Using Promises

const creatSheet =  await sheet.spreadsheets.create(res)

Link: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/create

codeekage avatar Jun 02 '19 17:06 codeekage

Where do you see the failing code in the documentation?

erickoledadevrel avatar Jun 03 '19 13:06 erickoledadevrel

Updated the issue with the link. Sorry for missing that out. 😅

codeekage avatar Jun 03 '19 13:06 codeekage

So using the key "responses" like you had in your original code will fail, but isn't what's shown on the page. The preferred key was recently changes to "requestBody", but it was a backwards compatible change and "resources" is still accepted.

https://github.com/googleapis/google-api-nodejs-client/pull/1149

Changing this to an enhancement to upgrade to v40 of the library and update our key to "requestBody".

erickoledadevrel avatar Jun 03 '19 14:06 erickoledadevrel