Commit db14fca6 authored by Jiawen Lyu's avatar Jiawen Lyu

deal with two promises

parent 9992ec08
......@@ -14,18 +14,23 @@ export default WrappedComponent => {
const fetchPromises = this.props.logins.map(login => {
return fetch(`https://webapplis.utc.fr/Edt_ent_rest/myedt/result/?login=${login}`)
.then(res => res.json())
.then(res =>
(res.map(elem => ({
login: login,
...elem
})))
)
})
Promise.all(fetchPromises).then(
(results) => {
// this.setState({
// isLoaded: true,
// data: this.state.data.concat(result.map(elem => ({
// login: login,
// ...elem
// }))),
// });
console.log("promise: ", results)
let allDatas = []
results.map(result => result.map(elem => allDatas.push(elem)))
console.log(results[0])
this.setState({
data: allDatas,
isLoaded: true
})
},
(error) => {
this.setState({
......
......@@ -61,7 +61,7 @@ const getAllDays = (term, day) => {
days = [...days, currentDay]
}
let dayArr = currentDay.split("-")
if ((dayArr[2] === 30 && dayArr[1] % 2 === 0) || (dayArr[2] === 31 && dayArr[1] % 2 === 1)) {
if ((dayArr[2] == 30 && dayArr[1] % 2 == 0) || (dayArr[2] == 31 && dayArr[1] % 2 == 1)) {
dayArr[2] = 1
dayArr[1]++
} else {
......@@ -103,9 +103,10 @@ const extractUvDateInfo = (uvs) => {
const withUVs = WrappedComponent => props => {
const { data } = props;
const uvs = extractUvDateInfo(data)
console.log("data: ", data)
console.log("uvs: ", uvs)
return <WrappedComponent events={demoData} {...props} />;
return <WrappedComponent events={uvs} {...props} />;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment