这是indexloc提供的服务,不要输入任何密码
Skip to content

The provided API key is invalid #1013

@bennycode

Description

@bennycode

If you copy the code snippet from the Quick Start, you will encounter an error message stating "The provided API key is invalid". This happens because the code example doesn't explicitly indicate that "key" refers to the API key. Unlike other samples below that specifically mention process.env.GOOGLE_MAPS_API_KEY, this crucial detail should also be included in the quick start code:

const client = new Client({});

client
  .elevation({
    params: {
      locations: [{ lat: 45, lng: -110 }],
      key: "asdf",
    },
    timeout: 1000, // milliseconds
  })
  .then((r) => {
    console.log(r.data.results[0].elevation);
  })
  .catch((e) => {
    console.log(e.response.data.error_message);
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions