aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.06k stars 573 forks source link

ApiGatewayManagementApiClient - error in the example code #6024

Closed Easy-Cloud-in closed 4 months ago

Easy-Cloud-in commented 5 months ago

Describe the issue

import { ApiGatewayManagementApiClient, DeleteConnectionCommand } from "@aws-sdk/client-apigatewaymanagementapi"; // ES Modules import
// const { ApiGatewayManagementApiClient, DeleteConnectionCommand } = require("@aws-sdk/client-apigatewaymanagementapi"); // CommonJS import
const client = new ApiGatewayManagementApiClient(config);
const input = { // DeleteConnectionRequest
  ConnectionId: "STRING_VALUE", // required
};
const command = new DeleteConnectionCommand(input);
const response = await client.send(command);
// {};

Property 'send' does not exist on type 'ApiGatewayManagementApiClient'

Links

https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/apigatewaymanagementapi/command/DeleteConnectionCommand/

RanVaknin commented 5 months ago

Hi @Easy-Cloud-in ,

I'm not sure why you are seeing this error. I'm able to run tsc on this code without any errors:

import { ApiGatewayManagementApiClient, DeleteConnectionCommand } from "@aws-sdk/client-apigatewaymanagementapi";

const client = new ApiGatewayManagementApiClient({region: "us-east-1"});
const input = { ConnectionId: "STRING_VALUE" };
const command = new DeleteConnectionCommand(input);

async function foo(){
  try {
    const response = await client.send(command)
    console.log(response)
  }catch(err){
    console.log(err)
  }
}
foo()
$ ls          
node_modules      package-lock.json package.json      sample.ts
$ tsc sample.ts 
$ ls
node_modules      package-lock.json package.json      sample.js         sample.ts

which SDK version and TS version are you using? Can I see the contents of your package.json and tsconfig if you have one?

Thanks, Ran~

github-actions[bot] commented 5 months ago

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

github-actions[bot] commented 4 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.