forked from skillrecordings/egghead-next
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstructors.ts
More file actions
38 lines (32 loc) · 774 Bytes
/
instructors.ts
File metadata and controls
38 lines (32 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import {request} from 'graphql-request'
export type Instructor = {
full_name: string
avatar_64_url: string
}
const endpoint = 'https://egghead.io/graphql'
export async function loadInstructors(page = 1) {
const query = `query getInstructors($page: Int!){
instructors(per_page: 24, page:$page){
id
full_name
avatar_url
slug
}
}`
const {instructors} = await request(endpoint, query, {page})
return instructors
}
export async function loadInstructor(slug: string) {
const query = `query getInstructor($slug: String!){
instructor(slug: $slug){
id
full_name
avatar_url
slug
bio_short
twitter
}
}`
const {instructor} = await request(endpoint, query, {slug})
return instructor
}