Skip to content

Async/Await example help - can't access data in response #268

Description

@crackernutter

Can some explain how to create an async/await function in ijavascript so I can get access to the actual data?

const makeRequest = async (config) => {
    const req = await axios.request(config);
    return req.data
}
data = makeRequest(config)

printing data in a cell returns

Promise {
  {
    objectIdFieldName: 'OBJECTID',
    uniqueIdField: { name: 'OBJECTID', isSystemMaintained: true },
    globalIdFieldName: '',
    geometryType: 'esriGeometryPoint',
    spatialReference: { wkid: 4269, latestWkid: 4269 },
    fields: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object]
    ],

So I can tell the request resolved, but then typing

data['objectIdFieldName']

returns nothing.
How do I access the actual data? I've tried JSON.parse, but that doesn't work either.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions