File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed
javascriptv3/example_code/location Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,15 @@ location_Hello:
2323 - description :
2424 snippet_tags :
2525 - location.java2.hello.main
26+ JavaScript :
27+ versions :
28+ - sdk_version : 3
29+ github : javascriptv3/example_code/location/
30+ sdkguide :
31+ excerpts :
32+ - description :
33+ snippet_tags :
34+ - javascript.v3.location.hello
2635 services :
2736 location : {ListGeofencesPaginator}
2837location_CreateMap :
Original file line number Diff line number Diff line change 1+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+ // SPDX-License-Identifier: Apache-2.0
3+
4+ // snippet-start:[javascript.v3.location.hello]
5+ import { fileURLToPath } from "node:url" ;
6+ import {
7+ LocationClient ,
8+ ListGeofenceCollectionsCommand ,
9+ } from "@aws-sdk/client-location" ;
10+
11+ /**
12+ * Lists geofences from a specified geofence collection asynchronously.
13+ */
14+ export const main = async ( ) => {
15+ const region = "eu-west-1" ;
16+ const locationClient = new LocationClient ( { region : region } ) ;
17+ const listGeofenceCollParams = {
18+ MaxResults : 100 ,
19+ } ;
20+ try {
21+ const command = new ListGeofenceCollectionsCommand ( listGeofenceCollParams ) ;
22+ const response = await locationClient . send ( command ) ;
23+ const geofenceEntries = response . Entries ;
24+ if ( geofenceEntries . length === 0 ) {
25+ console . log ( "No Geofences were found in the collection." ) ;
26+ } else {
27+ for ( const geofenceEntry of geofenceEntries ) {
28+ console . log ( `Geofence ID: ${ geofenceEntry . CollectionName } ` ) ;
29+ }
30+ }
31+ } catch ( error ) {
32+ console . error (
33+ `A validation error occurred while creating geofence: ${ error } \n Exiting program.` ,
34+ ) ;
35+ return ;
36+ }
37+ } ;
38+
39+ // snippet-end:[javascript.v3.location.hello]
40+
41+ // Invoke main function if this file was run directly.
42+ if ( process . argv [ 1 ] === fileURLToPath ( import . meta. url ) ) {
43+ main ( ) ;
44+ }
Original file line number Diff line number Diff line change 1+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+ // SPDX-License-Identifier: Apache-2.0
3+
4+ import { describe , it } from "vitest" ;
5+ import { main } from "../hello.js" ;
6+
7+ describe ( "test hello" , ( ) => {
8+ it (
9+ "should not re-throw service exceptions" ,
10+ async ( ) => {
11+ await main ( ) ;
12+ } ,
13+ { timeout : 600000 } ,
14+ ) ;
15+ } ) ;
You can’t perform that action at this time.
0 commit comments