Skip to Content
Phoenix Web Development
book

Phoenix Web Development

by Brandon Richey
April 2018
Beginner to intermediate content levelBeginner to intermediate
406 pages
9h 33m
English
Packt Publishing
Content preview from Phoenix Web Development

Expanding Our API Request

We have a good start to our code, but we should really expand on this a little bit more. In order for us to do that, we'll need to start off by modifying our controller. This should actually be very similar to what you've already seen in the past when displaying regular information to normal templates. We'll alias our Votes Context, grab the list of polls from our list_most_recent_polls/0 call, and then send that information on to our views! Let's take a look at the changes to lib/controllers/api/poll_controller.ex:

  alias Vocial.Votes  def index(conn, _params) do    polls = Votes.list_most_recent_polls()    render(conn, "index.json", polls: polls)  end

Next, we'll need to set up the process for our data to go from the database ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Phoenix in Action

Phoenix in Action

Geoffrey Lessel
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9781787284197Supplemental Content