The server response - a JSON list of products

Now we need to build the server endpoint. This will simply match the search keywords against our products. A real e-commerce site might have a sophisticated search that performs partial matching and relevance ranking of a database of products, but once again, this is out of scope here. In this prototype, only one search term will return data: tshirt.

When the user searches for tshirt, we'll return a JSON payload with a list of products in an array, like this:

{  "keywords": "tshirt",  "results": [    {      "name": "T-shirt: Super Pouvoir",      "price": "€9.99",      "description": "Super cool super power t-shirt",      "image": "img/tshirt-0-f-red-120.png"    },    {      "name": "T-shirt: La Biere",      "price": "€10.99", "description": ...

Get AMP: Building Accelerated Mobile Pages now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.