create fetch wrapper with mandatory user agent header
This commit is contained in:
13
app/helpers/fetchWrapper.js
Normal file
13
app/helpers/fetchWrapper.js
Normal 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;
|
||||||
Reference in New Issue
Block a user