Closed isaac8069 closed 2 years ago
<%if(apartment===undefined) {%>
<h3>No Results Found</h3>
<small>check your spelling and punctuation and try again</small>
<%} else {%>
<ul>
<%apartments.forEach(function(apartment) {%>
<li>
<a href="/apartment/<%=apartment.title%>">
<%=apartment.title%>
</a>
<small>(<%=apartment.rent%>)</small>
<small>(<%=apartment.location%>)</small>
</li>
<%})%>
</ul>
<%}%>
I have the correct url! I don't know why its not hitting the correct route
Three things I've tried:
I'm looking at your .render. Is your result.ejs within apartments in your directory structure?
When you say directory structure what are you referring to?
Your folders and files in your app.
Your .render should be rendering an .ejs file in your views.
Yes, result.ejs is within my apartments directory structure
.
In your controllers middleware, are you requiring the apartments url path?
Yes, I am requiring the apartments url path
The console log is bringing up another routes console log. When I comment the route out it brings up the search console log message. Not sure why. They have different URLs
I was looking for the middleware. App.use
Your GET route looks fine.
Could you show me the middleware? Should look like this: TAYLOR'S SNIPPET BELOW
I do not have that in my middleware.
Actually the middleware should say app.use('/apartments', require('./controllers/apartments'))
. If your current middleware is showing a singular /apartment
, then it means that the action on your search form is wrong and should be /apartment
(currently it's showing /apartments
)
Thats what I have
This is my form! It matches my controller in index.js
resolved!
SEARCH FOR AN APARTMENT USING LOCATION