I'm back inside of my blog context.
J.S. file taking a look at the blog post function we just put together.
So we're going to essentially update all these different action functions that we have so add blog post
delete and edit twelve make requests to our back API it should be a pretty straightforward process so
let's get to it.
I'm going to first start working on ADD blog post right here.
So inside of ADD blog post first begin by commenting out the dispatch and callback inside there.
We're just going to worry about making our requests to create a new blog post right now.
Oh then mark this function as a sink.
And then inside we'll add in our request using axioms so I'll do in a wait Jason server dot post remember
anytime we want to create a record on our back end server we're going to make a post request to make
a post to slash blog posts so I'll do a post request to slash blog posts.
And the second argument is going to be the information or the data that we want to send to our server.
So in our case it will be the title in content that we call this function with we're gonna send that
along inside of an object.
So we'll do title is title and content is content.
As usual our keys and values are identical.
So we can condense that down to just title and content like so so as soon as we run this line right
here and make a request we should be telling our Jason server to create a brand new blog post let's
do a quick test so I'll save this we can flip back over I'll go to my create form and then on the create
form I'll enter in a title of newly created API post and some content.
Remember we've not wired up our dispatch or the callback right here just yet.
So when we click save blog post or tap it on your device we're not gonna see anything really happen
on the screen right away.
So I'll go ahead and tap that.
And yes sure enough nothing quite happens.
However if you still have your code editor open with your DB Jason File Open inside of it.
Remember that's from our Jason server project directory.
You might see inside there are blog posts array now has a second blog post inside.
So that's the one we just created.
Notice how he was an assigned an idea of to remember Jason server automatically assigns ideas for us
to now to make sure that we can actually see this on our device.
We could do a refresh of our application to get back to our index screen so to do so if you are on a
simulator remember you can press commander or if you're on the android emulator you can it are and if
you're on a physical device you can shake your phone and hit reload alternately a much easier way is
to just make a change to your code and save it that will reload the application.
Now I can very easily see my newly created API post is now visible on this list.
Very good.
Now that we've got that working let's try to uncommon it just the callback for right now we won't worry
about doing that dispatch just yet.
So now after we attempt to create our request and after the request is successful we should then navigate
back to our index screen.
So I'll save this flip back over and I'll make a third post I'll hit plus I'll enter in third post creation
with some content.
Once again and I'll hit on safe blog post on those so we do navigate back.
But once we're back here I do not see the new blog post appear.
So it's a little bit unexpected but at the same time it is kind of expected as well.
So let's take a quick pause when we come back the next video we're going to figure out why we did not
see this API or steamy the new post appear after we made our post requests even though if I once again
check my DB Jason File here it is right here.
The third post definitely was created.
So for some reason it's not immediately appearing on the screen.
So let's figure that out in just a minute.