fix: 🐛 Fixed parsing bug for classmates
This commit is contained in:
parent
2f4826f578
commit
5f07259ddc
|
@ -4,7 +4,7 @@ import {
|
|||
CalendarItem, Child, Classmate, Fetch, RequestInit,
|
||||
} from './types'
|
||||
import {
|
||||
etjanst, child, calendarItem,
|
||||
etjanst, child, calendarItem, classmate,
|
||||
} from './parse'
|
||||
|
||||
export const list = (fetch: Fetch, init?: RequestInit) => async (): Promise<Child[]> => {
|
||||
|
@ -25,7 +25,7 @@ export const classmates = (fetch: Fetch, init?: RequestInit) => async (childId:
|
|||
const url = routes.classmates(childId)
|
||||
const response = await fetch(url, init)
|
||||
const data = await response.json()
|
||||
return etjanst(data)
|
||||
return etjanst(data).map(classmate)
|
||||
}
|
||||
|
||||
export const schedule = (fetch: Fetch, init?: RequestInit) => (
|
||||
|
|
27
run.js
27
run.js
|
@ -1,4 +1,5 @@
|
|||
const moment = require('moment')
|
||||
const { inspect } = require('util')
|
||||
const nodeFetch = require('node-fetch')
|
||||
const { CookieJar } = require('tough-cookie')
|
||||
const fetchCookie = require('fetch-cookie/node-fetch')
|
||||
|
@ -30,23 +31,23 @@ async function run() {
|
|||
|
||||
console.log('children')
|
||||
const children = await api.getChildren()
|
||||
// console.log(children)
|
||||
console.log(inspect(children, false, 10, true))
|
||||
|
||||
// console.log('calendar')
|
||||
// const calendar = await api.getCalendar(children[0])
|
||||
// console.log(calendar)
|
||||
console.log('calendar')
|
||||
const calendar = await api.getCalendar(children[0])
|
||||
console.log(inspect(calendar, false, 10, true))
|
||||
|
||||
// console.log('classmates')
|
||||
// const classmates = await api.getClassmates(children[0])
|
||||
// console.log(classmates)
|
||||
console.log('classmates')
|
||||
const classmates = await api.getClassmates(children[0])
|
||||
console.log(inspect(classmates, false, 10, true))
|
||||
|
||||
// console.log('schedule')
|
||||
// const schedule = await api.getSchedule(children[0], moment().subtract(1, 'week'), moment())
|
||||
// console.log(schedule)
|
||||
console.log('schedule')
|
||||
const schedule = await api.getSchedule(children[0], moment().subtract(1, 'week'), moment())
|
||||
console.log(inspect(schedule, false, 10, true))
|
||||
|
||||
// console.log('news')
|
||||
// const news = await api.getNews(children[0])
|
||||
// console.log(news)
|
||||
console.log('news')
|
||||
const news = await api.getNews(children[0])
|
||||
console.log(inspect(news, false, 10, true))
|
||||
|
||||
await api.logout()
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue