Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use global fetch if in browser environment, else use cross-fetch #23

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@
]
},
"dependencies": {
"@types/isomorphic-fetch": "^0.0.36",
"graphql": "^15.4.0",
"graphql-request": "^3.4.0",
"isomorphic-fetch": "^3.0.0"
"graphql-request": "^3.4.0"
},
"ava": {
"files": [
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {GraphQLClient} from 'graphql-request';
import fetch from 'isomorphic-fetch';
import {fetch as crossFetch} from 'cross-fetch';
njerig marked this conversation as resolved.
Show resolved Hide resolved
import {autocompleteSchoolQuery, searchTeacherQuery, getTeacherQuery} from './queries';
import {AUTH_TOKEN} from './constants';

const client = new GraphQLClient('https://www.ratemyprofessors.com/graphql', {
headers: {
authorization: `Basic ${AUTH_TOKEN}`
},
fetch
fetch: globalThis.fetch ?? crossFetch
});

export interface ISchoolFromSearch {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"lib": ["ES2017", "DOM"],
"lib": ["ES2017"],
"target": "es6",
"module": "commonjs",
"declaration": true,
Expand Down
Loading