https://i.sstatic.net/FYO7k.png
I have encountered an issue with my code where I am able to receive a response with status 200, however, the database is not updating. The backend has indicated that it received null data.
axios.post('api/nosql/LineController/insertLine', {
line:{
id:this.id,
directional:this.directional,
kilometer:this.slide1.distance,
runtime:runtime,
interval:this.slide2.shift,
type:this.type,
},
stationList: this.newPlatforms,
})
I attempted another approach with the following code, but the problem persisted.
axios({
method:"post",
changeOrigin:"true",
url:"api/nosql/LineController/insertLine",
transformRequest:[
function(data){
return QS.stringify(data);
}
],
data: {
line:{
id:this.id,
directional:this.directional,
kilometer:this.slide1.distance,
runtime:runtime,
interval:this.slide2.shift,
type:this.type,
},
stationList: this.newPlatforms,
}
})
The backend code snippet is as follows:
public Object insertLine(HttpServletRequest request) throws IOException {
StringBuffer lineInfoAndStations = new StringBuffer();
String line;
BufferedReader reader;
reader = request.getReader();
while(null != (line = reader.readLine())) {
lineInfoAndStations.append(line);
}
return service.addLine(lineInfoAndStations.toString());
}