We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The post resource should fulfill requirements below
Hint: phoenix doc
mix phoenix.gen.json Post posts title:string body:text
Then add route and migrate
Add the resource to your api scope in web/router.ex:
resources "/posts", PostController, except: [:new, :edit]
Remember to update your repository by running migrations:
$ mix ecto.migrate
Change ur route to be able to fulfill the requirements
In web/routes.ex, remove the except: [:new, :edit].
web/routes.ex
except: [:new, :edit]
Try to use ur newly created json post resource by sending POST requests to your server api.
Send the following as body in Postman:
body
{ "post": { "title": "First Post", "body": "Content" } }
Tip: Download Postman.
In web/controllers/post_controller.ex:
web/controllers/post_controller.ex
def create(conn, %{"post" => post_params}) do
expects a POST request as:
in contrast to:
def create(conn, post_params) do
which expects a POST request as:
{ "title": "First Post", "body": "Content" }
The text was updated successfully, but these errors were encountered:
VictorWinberg
antongoransson
easklund
martinjohansson93
saammirghorbani
ViktorClaesson
No branches or pull requests
[API] Posts
The post resource should fulfill requirements below
Generate a json post resource with title and body
Hint: phoenix doc
Spoiler
Then add route and migrate
Spoiler
Add the resource to your api scope in web/router.ex:
Remember to update your repository by running migrations:
Edit your json post resource as needed to fulfill requirements
Change ur route to be able to fulfill the requirements
Spoiler
In
web/routes.ex
, remove theexcept: [:new, :edit]
.Try to use ur newly created json post resource by sending POST requests to your server api.
Spoiler
Send the following as
body
in Postman:Tip: Download Postman.
Further notes:
In
web/controllers/post_controller.ex
:expects a POST request as:
in contrast to:
which expects a POST request as:
The text was updated successfully, but these errors were encountered: