So we have this Fontain, so in user click wanted to check out when we said there are to Déby and wait
for the response before we redirect them to this second.
So for that, we have this function.
OK, so let me just remove the alert and let me just lost control.
The card that we get from relax.
All right.
So this is the one this card we need to send back in so that we can save under the logged in users.
We're going to add the card, fill in the user schema, and that's what we're going to send this card
items.
Let me read this in.
You find this very easy to read in the console.
Know for when I click on this button.
Let's have a look.
When we get here in the console, when I click here to check out and take to this space.
But we should have the card in the console as well.
You can see this card.
It has multiple products of this information we need to send to back in so that we can see it.
So here we don't have the endpoint yet.
We have to even make some changes in the user schema.
But before we go to the back end, let's do whatever we need to do here in the front so that we can
easily give it a try later.
So let me just comment on.
So we're going to make a request and we can put that in our accents folder.
So sorry, not access, Frances.
We have these Frances, I think for this one, we need to create a new one.
Let's create a one called user, because this card will basically be related to use to use the Dodges
units involved, excuse from action and literally function export constantly user card.
So we need to send the card and we need to send the token.
And we're going to let's make sure it is async, so we're going to wait excuse dot bowstring to make
a posted list and if you use Congress, you need to make sure to use return.
I guess if you don't want to use Richen, don't use Carnaby's in this.
Alfonsin doesn't require a court address.
If you just have one line statement so we can read an excerpt, Axios Doorpost, we want to post to
our Bacons about that value we can get from forces dot in.
We don't.
We are FBI.
Less dangerous, less crowded.
So we're going to create this end point we don't have yet.
Then we're going to send the cart.
Now, make sure you grab this in this object, because later in the back and we will be able to access
this card array as request dogsbody, that card.
All right.
So if you don't use this one, then it will be available as just Renquist body and things can get a
little bit confusing.
So we have this in the Congress where we send it as an object object with the card value and it has
the value of it.
And then finally we send the letters and as I was talking, we sent and that is here.
OK, so we can use this function in the card.
So let's import that
import and use a card from.
So we are at the moment we're here.
So we need to go one step or get inside functions.
One of the functions you do, then we can use that.
So let me just right here, use a card.
So we need to give the card itself as an argument and second argument is the token.
So we need to send you the token, then we give the response response.
We can consider the response that the card post response response.
And then we're going to redirect that to take our case.
But we want to make sure we have the response.
So if response dot, dot, dot, dot.
Okay, so we will be sending this value.
OK, it will have the boolean value of either true or false.
So if we have been able to successfully say this card in the back and then only then we will be sending
the value of to the show.
OK, it will be true, otherwise it will be false.
Now we want to redirect only if the value is true.
So if response to data that OK, if that is true, then we are going to redirect the user to check out
using history.
Now if we come across an error, we can control.
Can a country like.
Can't save her.
So this is how we can send the cart in the back end to the back end so that we can save this under the
logged in users, our cart property in the database.
So that means we need to go back in to this end point that we just wrote security standpoint and create
a controller method that will save the card for the user in database.
So this method we need to create in the back end will be kind of dynamic one, because that will be
either creating or breeding.
Right.
So if the user have already added some items in the cart, then we're going to update when we make requests
for the second time.
Otherwise we're going to create art.
So let's see how we can do that in the next.