Best practice of handling item id on update


#1

Hi,
Please I want to find out the best practice for updating an item on the server using the item_id alongside user_id.
This is what I want to do

bookRide(data)
  {
  	this.rideservice.bookRide(this.bookData).then((result) => {
      this.viewCtrl.dismiss();
      this.navCtrl.pop();
    }, (err) => {
      this.loading.dismiss();
      this.presentToast(err);
      console.log(err);
    });
  }

This is my item.ts

this.http.post(`${Config.API_URL}/ride/book/id`, data, this.requestOptions).toPromise();

Here is the service provider and finally

<form (submit)="bookRide(bookride.id)">
  <ion-card>

  <ion-card-header>
    Select Seat Number
  </ion-card-header>

	<ion-list >

		 <ion-item>
			      <ion-label stacked>Car Make</ion-label>
			      <ion-input [(ngModel)]="bookData.id" name="id" type="hidden" value="{{ bookride.id }}" placeholder="Your Name" ></ion-input>
			    </ion-item>
	  <ion-item>
	    <ion-label>Select ...</ion-label>
	    <ion-select [(ngModel)]="bookData.number_of_seats" name="number_of_seats">
	      <ion-option value="1">1</ion-option>
	      <ion-option value="2">2</ion-option>
	      <ion-option value="3">3</ion-option>
	      <ion-option value="4">4</ion-option>
	    </ion-select>
	  </ion-item>
	 </ion-list>

	 <button ion-button class="jr_offer_ride2" type="submit">
		Book Ride
	</button>
   </ion-card>

	
</form>

The form am submitting


#2

Ok.

And what is your problem or actual question?
Is your code not working?
What exactly is not working?


#3

I want to pass the id from the html page to the server alongside the user_id, The code above isn’t working. Server respond with code 500 and the ride id am supposed to pass doesn’t get there. I have a rides table and I want to update it with the number_of_seats field and that using the ride_id


#4

Everything in this situation that I can think of having a “best practice” is on the server side. As far as the client code goes, the best practice is to feed the server what it wants in the format it expects.


#5

So this is what i want to do;
On that detail.ts page, I pass the ride details which include the ride_id, so what i want to do now is make a form that takes in the ride_id as one of the parameters alongside one other parameter.
How do I go about that??
So far, I passing the ride_id aloigside the form is the issue here.
Thanks


#6

So I also appended the ride_id but it’s not successfully passing to the server


#7

What does that mean? Is it not part of the HTTP request? Or does you server not like the request it is getting?


#8

On that detail.ts page, I pass the ride details which include the ride_id, so what i want to do now is make a form that takes in the ride_id as one of the parameters alongside one other parameter.
How do I go about that??
So far, I passing the ride_id aloigside the form is the issue here.