The data stored in the request variable in my code snippet is as follows:
{widgetName: "widgetName", widgetCriteria: "Activities", followUpDate: "1591727400000", uid: "someId"}
let request = JSON.parse(JSON.stringify(Object.assign(this.registrationForm.value, ...req)));
delete request.widgetFIlterOptions;
let uid = JSON.parse(window.localStorage.getItem("user")).uid;
request.uid = uid;
this.openWindow = false;
console.info("request-->", request);
this.contactService.addWidget(request).subscribe(res=> {
this.emService.updateWidgits();
})
When invoking the addWidget() function/method, a post request is submitted. However, after the post request is sent, I am facing an issue with the absence of the "followUpDate" parameter in the received response from the ResetController class.
I am seeking assistance to resolve this matter. As a newcomer to Angular, I may have overlooked something crucial here.
addWidget(widget, data?) {
console.info("widget-->", widget); // the followUpDate field exists here
this.http.post(this.api.createWidget, widget).pipe(map(data => {
console.info("data-->", data); // however, the followUpDate is not present in this data.
let message = "Widget created successfully";
data['data'] = this.filterWidgets(data).length > 0 ? this.filterWidgets(data): alert("No data Available");
this.widgets.unshift(data);
this.toastr.success(message);
}),catchError(err => {
this.toastr.error(err.error);
return throwError(err);
}));
The following excerpt showcases my RestController class:
@RestController
public class DashboardController {
@Autowired
Service service;
@PostMapping(path = "createcriteria", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "create the deal", response = Dashboard1.class)
public Dashboard1 saveCriteria(@RequestBody Dashboard1 dashboard1) {
System.out.println(dashboard1); // here, the "followUpDate" field is missing
return service.saveCriteria(dashboard1);
}
}
Below is the structure of my Dashboard1 class:
@Document(collection = "Dashboard1")
@JsonInclude(Include.NON_NULL)
public class Dashboard1 {
@Id
@ApiModelProperty(notes = "The database generated product ID")
private String id;
@Field(value = "widgetname")
private String WidgetName = null;
@Field(value = "widgetcriteria")
private String WidgetCriteria = null;
@Field(value = "uid")
private String uid = null;
@Field(value = "activitytype")
private String activityType = null;
@Field(value = "contactname")
private String contactName = null;
@Field(value = "updateby")
private String updateBy = null;
@Field(value = "followUpDate")
private String followUpDate = null;
// Includes all getter, setter, and toString() methods below
}