Created
June 29, 2022 13:40
-
-
Save adityatelange/c6da27ed98800546d6ec0cecbce2ea34 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args)); | |
// The main, exported, function of the endpoint, | |
// dealing with the request and subsequent response | |
module.exports = async (req, res) => { | |
const url = req.query.url || req.body.url; | |
const res = await fetch(url, { | |
method: 'GET', | |
}); | |
// Store fetched HTML in data | |
const data = await res.text(); | |
res.status(200).send(data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment