From 5f07259ddc6dd24ed29dbff81dc03f8ae7159e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20=C3=96brink?= Date: Mon, 21 Dec 2020 16:13:31 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fixed=20parsing=20bug=20f?= =?UTF-8?q?or=20classmates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/children.ts | 4 ++-- run.js | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/children.ts b/lib/children.ts index 5045e577..9fba7b1e 100644 --- a/lib/children.ts +++ b/lib/children.ts @@ -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 => { @@ -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) => ( diff --git a/run.js b/run.js index eaf338b7..118981d6 100644 --- a/run.js +++ b/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() })