daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 a, int b){
  4.     calculatedValues.setA(a);
  5.     calculatedValues.setB(b);
  6.  
  7.     System.out.println(calculatedValues.getA());
  8.     System.out.println(calculatedValues.getB());
  9.  
  10.     return a * b;
  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.             a: this.state.a,
  25.             b: this.state.b
  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);
  33.         console.log(error.response.data);
  34.     });
  35. }
  36.    
  37. constructor (props) {
  38.     super(props);
  39.  
  40.     this.state = {
  41.         a: 0,
  42.         b: 0
  43.     }
  44.  
  45.     this.SetA = this.SetA.bind(this);
  46.     this.SetB = this.SetB.bind(this);
  47.     this.CalculateNumbers =  this.CalculateNumbers.bind(this);
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top