Skip to content

Instantly share code, notes, and snippets.

@rabwill
Created August 8, 2023 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rabwill/e1afd263703a9c4e1f9fee1cf0a7d744 to your computer and use it in GitHub Desktop.
Save rabwill/e1afd263703a9c4e1f9fee1cf0a7d744 to your computer and use it in GitHub Desktop.
GitHub Copilot blog prompt 3
//create an asynchoronous API service to return product searching the products array by name , not case sensitive and includes string
server.get("/api/products/:name", async (req, res) => {
const name = req.params.name;
const product = products.filter((product) => product.name.toLowerCase().includes(name.toLowerCase()));
if (product) {
res.send(product);
} else {
res.send(404);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment