0

I am getting this error when trying to run the code below (I am using the script editor in Airtable for those familiar). The API output is an XML string that I am converting to an object with some code I found on Github.

let response = await fetch('https://myapiendpoint.com/parameters', 

{
    method: 'GET',
    headers: {
        'apikey': 'MY KEY'
    },
})

let myResponse = parseXML(await response.text())

console.log(myResponse)
console.log(Object.keys(myResponse))
console.log(myResponse.Users.User.FirstName)

Console Log

You can see that even though I am using the correct key, I am still getting an error when trying to call the FirstName key from the third console.log line.

Any assistance would be greatly appreciated

  • Get familiar with [how to access and process objects, arrays, or JSON](/q/11922383/4642212), how to [access properties](//developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Property_Accessors), and what [objects](//developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Object_initializer) and [arrays](//developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/Array#array_literal_notation) look like. See also [JavaScript property access: dot notation vs. brackets?](/q/4968406/4642212). Clearly, `myResponse.Users` doesn’t exist. – Sebastian Simon Nov 23 '22 at 20:36

0 Answers0