Guest User

Untitled

a guest
Jan 23rd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. @PostMapping(value = "/multiplyparams", consumes = {"application/x-www-form-urlencoded"}, produces = MediaType.APPLICATION_JSON_VALUE)
  2. @CrossOrigin(origins = "http://localhost:3000")
  3. public int MultiplyParams(int num1, int num2){
  4. calculatedValues.setA(num1);
  5. calculatedValues.setB(num2);
  6.  
  7. System.out.println(calculatedValues.getA());
  8. System.out.println(calculatedValues.getB());
  9.  
  10. return num1 * num2;
  11. }
  12.  
  13. CalculateNumbers() {
  14. console.log(this.state.a);
  15. console.log(this.state.b);
  16.  
  17. axios({
  18. method: 'post',
  19. headers: {
  20. 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
  21. },
  22. url: 'http://localhost:8080/multiplyparams',
  23. data: {
  24. 'num1': this.state.num1,
  25. 'num2': this.state.num2
  26. }
  27. }).then(response => {
  28. console.log(response);
  29. console.log(response.data);
  30. }).catch(error => {
  31. console.log(error.message);
  32. console.log(error.response.data);
  33. });
  34. }
  35.  
  36. constructor (props) {
  37. super(props);
  38.  
  39. this.state = {
  40. num1: 0,
  41. num2: 0
  42. }
  43.  
  44. this.SetA = this.SetA.bind(this);
  45. this.SetB = this.SetB.bind(this);
  46. this.CalculateNumbers = this.CalculateNumbers.bind(this);
  47. }
Add Comment
Please, Sign In to add comment