Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2.  
  3. let list = []
  4.  
  5. class App extends Component {
  6.   constructor(props) {
  7.     super(props);
  8.     this.state = {
  9.       data: null,
  10.       list: []
  11.     };
  12.   }
  13.  
  14.   componentDidMount() {
  15.     fetch('https://visningsrom.stacc.com/dd_server_laaneberegning/rest/laaneberegning/v1/nedbetalingsplan', {
  16.       method: 'POST',
  17.       headers: {
  18.         Accept: 'application/json',
  19.         'Content-Type': 'application/json'
  20.       },
  21.       body: JSON.stringify({
  22.         "laanebelop": 2000000,
  23.         "nominellRente": 3,
  24.         "terminGebyr": 30,
  25.         "utlopsDato": "2045-01-01",
  26.         "saldoDato": "2020-01-01",
  27.         "datoForsteInnbetaling": "2020-02-01",
  28.         "ukjentVerdi": "TERMINBELOP"
  29.       })
  30.     })
  31.       .then(response => response.json())
  32.       .then(data => {
  33.         console.log(data)
  34.         this.setState({
  35.           data: data
  36.         })
  37.         data.nedbetalingsplan.innbetalinger.forEach(elem => {
  38.           list.push(elem)
  39.         })
  40.         console.log("the list")
  41.         console.log(list)
  42.       })
  43.       .then(() => {
  44.         list.forEach(elem => {
  45.           li.push(elem.dato)
  46.         })
  47.         console.log(li)
  48.       })
  49.   }
  50.  
  51.  
  52.  
  53.  
  54.   render() {
  55.     return(
  56.       <div>
  57.         {li}
  58.       </div>
  59.     )
  60.   }
  61. }
  62.  
  63. const li = []
  64.  
  65. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement