Created
August 8, 2023 00:08
-
-
Save rabwill/e1afd263703a9c4e1f9fee1cf0a7d744 to your computer and use it in GitHub Desktop.
GitHub Copilot blog prompt 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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