I simply want to send a value to my rest api in a fetch method but can't seem to get it to work. This is what I have currently:
React:
getFloorplans() {
fetch('/api/ssid')
.then(response => response.json())
.then(message => {
this.setState({
floorplan: message[0]
})
});
fetch('/api/ssid', {
method: "POST",
//make sure to serialize your JSON body
value: {ssid: this.state.SSID}
})
.then( (response => response.json()
.then(message => {
console.log(message);
})
))};
Spring boot rest api:
@RestController
public class FloorplanController {
//Floorplan floorplan = new Floorplan();
@RequestMapping("/api/ssid")
public void someMethod(@RequestParam String value) {
System.out.println(value);
}
}

@PostMapping("/api/ssid")if you are performing a POST request, the HTTP method is not specified at the moment. Second thing, I don't know a lot of React, but if you are sending your value as a JSON body you should use@RequestBodyin your method.bodyinstead ofvalue, as that is whatfetchexpects: developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch