Create fetch wrapper with user agent #98

Merged
bilal.catic merged 3 commits from create-fetch-wrapper-with-user-agent into master 2020-02-20 20:58:33 +01:00
Showing only changes of commit f62a7200c7 - Show all commits

View File

@@ -0,0 +1,13 @@
const nodeFetch = require("node-fetch");
const fetch = async (url, options = {}) => {
const newOptions = Object.assign({}, options);
if (!newOptions["headers"]) {
newOptions["headers"] = {};
}
newOptions["headers"]["User-Agent"] =
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36";
return nodeFetch(url, newOptions);
};
module.exports = fetch;