Skip to content

Commit

Permalink
fix: 🐛 Fixed parsing bug for classmates
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanObrink committed Dec 21, 2020
1 parent 2f4826f commit 5f07259
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lib/children.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]> => {
Expand All @@ -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) => (
Expand Down
27 changes: 14 additions & 13 deletions run.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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()
})
Expand Down

0 comments on commit 5f07259

Please sign in to comment.