generated from aws-samples/amplify-vite-react-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding twelvelabs api call test
- Loading branch information
Showing
6 changed files
with
127 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import type { APIGatewayProxyHandler } from "aws-lambda"; | ||
import { TwelveLabs } from "twelvelabs-js"; | ||
|
||
export const handler: APIGatewayProxyHandler = async (event) => { | ||
console.log("event", event); | ||
const client = new TwelveLabs({ apiKey: "<YOUR_API_KEY>" }); | ||
return { | ||
statusCode: 200, | ||
// Modify the CORS settings below to match your specific requirements | ||
headers: { | ||
"Access-Control-Allow-Origin": "*", // Restrict this to domains you trust | ||
"Access-Control-Allow-Headers": "*", // Specify only the headers you need to allow | ||
}, | ||
body: JSON.stringify("Hello from myFunction!"), | ||
body: JSON.stringify(client), | ||
}; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { get } from "aws-amplify/api"; | ||
|
||
export async function getItem() { | ||
try { | ||
const restOperation = get({ | ||
apiName: "myRestApi", | ||
path: "items", | ||
}); | ||
const { body } = await restOperation.response; | ||
// consume as a string: | ||
const str = await body.text(); | ||
console.log("GET call succeeded: ", str); | ||
} catch (error) { | ||
console.log("GET call failed: ", JSON.parse(error as string)); | ||
} | ||
} |