File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
tutorial/markdown/nodejs/dataApi-appsync-tutorial Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ export function request(ctx) {
200200
201201 // Construct a SQL++ query to filter hotels by city
202202 // The query_context below lets us use "hotel" instead of "travel-sample.inventory.hotel"
203- const sql_query = ` SELECT c.* FROM ${ collection} AS c WHERE city = \" ${ city} \" ` ;
203+ const sql_query = ` SELECT c.* FROM ${ collection} AS c WHERE city = $ city` ;
204204
205205 // Build the HTTP request object for the Data API Query Service
206206 const requestObject = {
@@ -212,11 +212,12 @@ export function request(ctx) {
212212 ' Content-Type' : ' application/json' ,
213213 ' Authorization' : auth // Dynamic Basic auth per request
214214 },
215- body: {
215+ body: JSON . stringify ( {
216216 query_context: ` default:${ bucket} .${ scope} ` , // Namespace shortcut
217217 statement: sql_query, // The SQL++ query
218+ args: { city: city }, // Pass parameters securely
218219 timeout: ' 30m' // Query timeout (generous for demo)
219- }
220+ })
220221 }
221222 };
222223 return requestObject;
You can’t perform that action at this time.
0 commit comments