Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function getMatches() {
const res = await fetch('/api');
const data = await res.json();
// Filters array from the API for resources with keywords containing user value
const matches = data.filter(resource => resource.keywords.some(str => str.includes(keyword)));
const matches = data.filter(resource => resource.keywords.some(str => str.toLowerCase().includes(keyword)));
renderMatches(matches);
} catch (err) {
console.error(err);
Expand Down
4 changes: 1 addition & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -31,7 +29,7 @@ app.get('/api/:keyword', (req, res) => {
const keyword = req.params.keyword.toLowerCase();

// filter resources array, return items that match query; tag.
const matches = resources.filter((obj) => obj.keywords.some(str => str.includes(keyword)));
const matches = resources.filter((obj) => obj.keywords.some(str => str.toLowerCase().includes(keyword)));

// if matches were found, respond with matches array in JSON format
if (matches.length) {
Expand Down