javascript - refresh error on devextreme scheduler's plugin - angular 4 -


i'm trying make appointment scheduler's app using devextreme scheduler. have little bug. know why, when create appointment , drag , drop appointment create have error on console :

put http://localhost/v0/croissant/undefined 404 (not found) appointment.service.ts:19 error occurred response {_body: "", status: 404, ok: false, statustext: "not found", headers: headers…} webpackjsonp.../../../../../src/app/services/appointment.service.ts.appointmentservice.handleerror @ appointment.service.ts:19 zonedelegate.invoke @ zone.js:203 oninvoke @ core.es5.js:3890 zonedelegate.invoke @ zone.js:202 zone.run @ zone.js:96 (anonymous) @ zone.js:462 zonedelegate.invoketask @ zone.js:236 oninvoketask @ core.es5.js:3881 zonedelegate.invoketask @ zone.js:235 zone.runtask @ zone.js:136 drainmicrotaskqueue @ zone.js:368 zonetask.invoke @ zone.js:308 core.es5.js:1020 error error: uncaught (in promise): response status: 404 not found url: http://localhost/v0/croissant/undefined 

but when refresh page , move appointment, works fine...

here update appointment method on appointment.service.ts

updateappointment(id: string, userid :string, timestamp :string, reason: string): promise<appointment>{      let bodysearchparam = new urlsearchparams();     bodysearchparam.append('userid', userid );     bodysearchparam.append('timestamp', this.datetotimestamp(timestamp).tostring());     bodysearchparam.append('reason', reason);     let body = bodysearchparam.tostring();       var appointmenturlupdate = this.appointmenturlwrite + "/" + id;      return this.http.put(appointmenturlupdate, body)                     .topromise()                     .then(response =>                       console.log("event updated")                     )                     .catch(this.handleerror);    } 

here eventhandler on calendar component

  updateappointment(e: any){     e.appointmentdata.enddate = this.add30mnto(e.appointmentdata.startdate); // bugfix pour l'affichage du calendrier     this.appointmentservice.updateappointment(e.appointmentdata.id, e.appointmentdata.ownerid, e.appointmentdata.startdate, e.appointmentdata.text)   } 

and here call eventhandler on calendar.component.html

<dx-scheduler     (onappointmentupdated)= "updateappointment($event)" >  </dx-scheduler> 

thank's !

the problem is, api need , id update appointment. id isn't stored now. resolution's method :

  createappointment(userid :string, timestamp :string, reason: string): promise<appointment> {      let bodysearchparam = new urlsearchparams();     bodysearchparam.append('userid', userid );     bodysearchparam.append('timestamp', this.datetotimestamp(timestamp).tostring());     bodysearchparam.append('reason', reason);     let body = bodysearchparam.tostring();      console.log(body)     return this.http.post(this.appointmenturlwrite,body)                   .topromise()                   .then(response =>                     this.createdid = response.json().id // appointment's id                   )                   .catch(this.handleerror);   } 

make function returns createdid:

  getcreatedid(){     return this.createdid;   } 

and on updateappointment method :

if(e.appointmentdata.id == null){e.appointmentdata.id = this.appointmentservice.getcreatedid();} 

the condition serves appointment who's have id ( of appointment have id after refreshing page)

hope can serve 1 :)


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -