Google Sheets spreadsheets.values.update not working when using axios

I am working on a simple internal react native application for my company. I am trying to update an excel sheet using google’s apis via axios requests. I have used Google’s oAuth (via Firebase) and am authenticated properly.

Here is the code (be advised that some of the variables are not used yet. I will update that when this code works):

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>const doWriteToGoogleSheets = async (sheetId, sheetName, range, majorDimension) => {
await axios.put(`https://sheets.google.com/v4/spreadsheets/${sheetId}/values/${sheetName}!${range}?valueInputOption=${VALUE_INPUT_OPTION.USER_ENTERED}&key=${AUTH_SHEETS_API_KEY}`, {
range: `${sheetName}!${range}`,
majorDimension: "ROWS",
values: [
["NAMESS"] // test value, try with only 1 cell as the range
],
})
}
</code>
<code>const doWriteToGoogleSheets = async (sheetId, sheetName, range, majorDimension) => { await axios.put(`https://sheets.google.com/v4/spreadsheets/${sheetId}/values/${sheetName}!${range}?valueInputOption=${VALUE_INPUT_OPTION.USER_ENTERED}&key=${AUTH_SHEETS_API_KEY}`, { range: `${sheetName}!${range}`, majorDimension: "ROWS", values: [ ["NAMESS"] // test value, try with only 1 cell as the range ], }) } </code>
const doWriteToGoogleSheets = async (sheetId, sheetName, range, majorDimension) => {
    await axios.put(`https://sheets.google.com/v4/spreadsheets/${sheetId}/values/${sheetName}!${range}?valueInputOption=${VALUE_INPUT_OPTION.USER_ENTERED}&key=${AUTH_SHEETS_API_KEY}`, {
        range: `${sheetName}!${range}`,
        majorDimension: "ROWS",
        values: [
            ["NAMESS"] // test value, try with only 1 cell as the range
        ],
    })

}

I have also tested using:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> await axios.put(`https://sheets.google.com/v4/spreadsheets/${sheetId}/values/'TimeFullYear (Input Here)'!A1?valueInputOption=${VALUE_INPUT_OPTION.USER_ENTERED}&key=${AUTH_SHEETS_API_KEY}`, {
"range": "'TimeFullYear (Input Here)'!A1",
"majorDimension": "ROWS",
"values": [
[
"NAMESS"
]
]
})
</code>
<code> await axios.put(`https://sheets.google.com/v4/spreadsheets/${sheetId}/values/'TimeFullYear (Input Here)'!A1?valueInputOption=${VALUE_INPUT_OPTION.USER_ENTERED}&key=${AUTH_SHEETS_API_KEY}`, { "range": "'TimeFullYear (Input Here)'!A1", "majorDimension": "ROWS", "values": [ [ "NAMESS" ] ] }) </code>
    await axios.put(`https://sheets.google.com/v4/spreadsheets/${sheetId}/values/'TimeFullYear (Input Here)'!A1?valueInputOption=${VALUE_INPUT_OPTION.USER_ENTERED}&key=${AUTH_SHEETS_API_KEY}`, {
        "range": "'TimeFullYear (Input Here)'!A1",
        "majorDimension": "ROWS",
        "values": [
            [
                "NAMESS"
            ]
        ]
    })

and

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> await axios.put(`https://sheets.google.com/v4/spreadsheets/${sheetId}/values/'TimeFullYear (Input Here)'!A1?valueInputOption=${VALUE_INPUT_OPTION.USER_ENTERED}&key=${AUTH_SHEETS_API_KEY}`, {
range: "TimeFullYear (Input Here)!A1",
majorDimension: "ROWS",
values: [
[
"NAMESS"
]
]
})
</code>
<code> await axios.put(`https://sheets.google.com/v4/spreadsheets/${sheetId}/values/'TimeFullYear (Input Here)'!A1?valueInputOption=${VALUE_INPUT_OPTION.USER_ENTERED}&key=${AUTH_SHEETS_API_KEY}`, { range: "TimeFullYear (Input Here)!A1", majorDimension: "ROWS", values: [ [ "NAMESS" ] ] }) </code>
  await axios.put(`https://sheets.google.com/v4/spreadsheets/${sheetId}/values/'TimeFullYear (Input Here)'!A1?valueInputOption=${VALUE_INPUT_OPTION.USER_ENTERED}&key=${AUTH_SHEETS_API_KEY}`, {
        range: "TimeFullYear (Input Here)!A1",
        majorDimension: "ROWS",
        values: [
            [
                "NAMESS"
            ]
        ]
    })

THE PROBLEM

My logger is saying that the code completed successfully (no error was thrown) but then I get “undefined” as a response (after the “:” is where the response should be):

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>SUCCESS - write to timecards: undefined
</code>
<code>SUCCESS - write to timecards: undefined </code>
SUCCESS - write to timecards: undefined

And when I check in the google sheet nothing is updated.

WHAT I KNOW

  • I am authenticated properly. I know this as my Google Sheets get request does work
  • I have enabled the required scopes (https://www.googleapis.com/auth/spreadsheets)

HELP

can someone help me out?

EDIT

  • VALUE_INPUT_OPTION.USER_ENTERED is equal to the string “USER_ENTERED”
  • I am following these docs: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật