OK.
So in this video we're going to focus on taking the result data that we're getting from the API.
Still the hardcoded Calif. and displaying it using edged him out so all that we need to do really is
take this results data and send it to a template.
So first thing we need to do is configure our app so app does set view engine.
And I always forget about the space here and I try and do a few engine but it's not the case we need
space and we're going to set it to Ejay us and save.
And we already have that required and installed for our package.
Jason then what we'll do is make our views directory.
So make directory views then we will create the file use results.
E.J..
Yes.
OK.
Now let's go ahead and open up that file which is in here views results study J.S..
Start simple with an H1 results page should we review rather than doing this redstart send and you get
rid of that and do a red dot render results.
So that should render results study.
Yes let's just double check started for server no problems.
There we go.
We get results page.
Excellent.
So all we need to do is pass this data into our template so that we can use it.
So it's going to be confusing naming everything results.
Let's change the name here to just data then we'll pass that in.
So say inside the template data is data.
So pass this parsed body call data into a template and we'll just keep the name as data and that's it
.
Now in our template we have access to data and if we just save it like that I'll need to restart the
server and refresh.
You just see an object but we know what that object looks like.
And this is where it's helpful to use adjacent to your.
It looks like this.
And we know that you need to access the search key.
And then we have an array and we'll need to loop through that array with a for loop or a for each and
will display each title.
So give it a shot.
First thing is we want data search and we don't need to display it anymore.
So we're going to do a loop on data search.
So again that gives us this array here.
So it's an array we can loop through it we'll do it for each and we'll call each one a movie and then
at our closing races here that I always forget about and we'll start simple by displaying movie title
.
Great.
And let's just play each one as an ally
just like that.
And let's see what happens.
So we're accessing search inside of data and then we're running for each on that for each movie make
an ally with the title and there we go.
That is a list of movies that we're getting from that API.
So we could go here and change California to now be Iowa restarted and ten different movies TV shows
that CSI Iowa that have Iowa and the title Vanilla Ice live at the Iowa State Fair.
Cool.
So that's all there is to the results page.
Well almost all there is now we need to hook it up to a search page that doesn't exist yet and that
search page is going to have a form and this right here.
Iowa will actually be a variable that will be coming from that format so won't always be Iowa.
It will be whatever the user types in to the search route.
So in the next video will set up the search route and get it connected to the results page.
Awesome