From ef0bbbb5f99c8a55e7aeeb410ac0d07dc88437e2 Mon Sep 17 00:00:00 2001 From: brianschnee Date: Mon, 13 Jun 2022 22:12:41 -0400 Subject: [PATCH 1/2] fixed client side search when resource was not found --- public/js/main.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/public/js/main.js b/public/js/main.js index fe434d7..a7d3a3d 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -30,14 +30,20 @@ function renderMatches(matches) { list.innerHTML = ''; // For every match found, render the objects to the DOM in JSON format - matches.forEach(match => { - const li = document.createElement('li'); + if(matches.length > 0) { + matches.forEach(match => { + const li = document.createElement('li'); - // Create an element that looks like a JSON object for every match - li.innerHTML = ` -
{

name: '${match.name}',
url: '${match.url}',
keywords: [${match.keywords.map(keyword => `'${keyword}'`).join(", ")}]
},
- `; + // Create an element that looks like a JSON object for every match + li.innerHTML = ` +
{

name: '${match.name}',
url: '${match.url}',
keywords: [${match.keywords.map(keyword => `'${keyword}'`).join(", ")}]
},
+ `; + list.appendChild(li); + }); + } else { + const li = document.createElement('li'); + li.innerText = 'No matches were found.'; list.appendChild(li); - }); + } } \ No newline at end of file From 2fd3572dbb74be34765d5d2b9ac8d9b66fc2b618 Mon Sep 17 00:00:00 2001 From: Brian Schnee <77141303+brianschnee@users.noreply.github.com> Date: Mon, 13 Jun 2022 22:16:40 -0400 Subject: [PATCH 2/2] Update server.js --- server.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/server.js b/server.js index 4f85cc3..f13c0b2 100644 --- a/server.js +++ b/server.js @@ -2,8 +2,6 @@ const express = require('express'); const app = express(); const cors = require('cors'); const { resources } = require("./resources"); -const { response } = require('express'); -const e = require('express'); const PORT = process.env.PORT || 8000; app.set('view engine', 'ejs')