Created
October 27, 2020 19:35
-
-
Save gagregrog/413cb3490e67f1d6e63bcc3aff52bc44 to your computer and use it in GitHub Desktop.
Request UW COVID-19 Test Results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetch = require('node-fetch'); | |
const { URLSearchParams } = require('url'); | |
const METHOD = 'POST'; | |
const URL = 'https://securelink.labmed.uw.edu/result'; | |
const getTestResultsAsHtml = async ({ dob, barcode }) => { | |
if (!(dob && barcode)) { | |
throw new Error('dob and code are required'); | |
} | |
const params = new URLSearchParams(); | |
params.append('dob', dob); | |
params.append('barcode', barcode); | |
console.log('Checking for updated results...\n'); | |
// using URLSearchParams, the Content-Type header is set automatically | |
const res = await fetch(URL, { method: METHOD, body: params }); | |
return res.text(); | |
} | |
module.exports = getTestResultsAsHtml; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment