From ab9021ad0fe10423103fb7407da6248cf9c761fa Mon Sep 17 00:00:00 2001 From: Daniel Hutzel Date: Fri, 8 Aug 2025 06:55:01 +0200 Subject: [PATCH 1/2] Using hcql protocol adapter (experimental) --- app/vue/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/vue/app.js b/app/vue/app.js index 66479a3..4bc667b 100644 --- a/app/vue/app.js +++ b/app/vue/app.js @@ -1,7 +1,7 @@ import { createApp, ref, reactive } from './vue.js' import cds from './cap.js' -const { GET, POST } = cds.connect.to ('/rest/catalog') +const { GET, POST } = cds.connect.to ('/hcql/catalog') const $ = s => document.querySelector (s) createApp ({ setup() { @@ -16,14 +16,14 @@ createApp ({ setup() { return { books, book, order, message, stars, async fetch ($) { - books.value = await GET `ListOfBooks?$expand=genre($select=name),currency($select=symbol)${ - $ ? `&$search=${$}` : '' + books.value = await GET `ListOfBooks { *, genre.name as genre, currency.symbol as currency } ${ + $ ? `where $search('${$}')` : '' }` }, async inspect (index) { message.reset() let { ID } = book.value = books.value [index] - Object.assign (book.value, await GET `Books/${ID}?$select=descr,stock`) + Object.assign (book.value, await GET `Books/${ID} { descr, stock }`) Object.assign (order, { book: ID, quantity: 1 }) // reset order for selected book setTimeout (()=> $('form > input').focus(), 11) // focus input field after rendering }, From 16401aff0b08bf375f171e9a1ff3576b5558f211 Mon Sep 17 00:00:00 2001 From: Daniel Hutzel Date: Wed, 3 Sep 2025 11:33:51 +0200 Subject: [PATCH 2/2] . --- app/vue/cap.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/vue/cap.js b/app/vue/cap.js index 35c5351..06c9c06 100644 --- a/app/vue/cap.js +++ b/app/vue/cap.js @@ -4,12 +4,12 @@ * import fetch from 'cap.js'; const { GET, POST } = fetch.for ('/rest/catalog') */ export default { - connect: { to: (base, defaults) => new Fetcher (base, defaults) }, - for: (base, defaults) => new Fetcher (base, defaults), + connect: { to: (base, defaults) => new ServiceClient (base, defaults) }, + for: (base, defaults) => new ServiceClient (base, defaults), } /** A CAP Service lookalike for HTTP clients */ -export class Fetcher { +export class ServiceClient { // These are convenience methods that still return standard fetch Response objects options (..._) { return this.fetch ('OPTIONS', ..._) }