Skip to content

Commit

Permalink
fix fetch instance
Browse files Browse the repository at this point in the history
  • Loading branch information
kalkih committed Apr 5, 2022
1 parent f8df936 commit ab51fbc
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/services/bookingService.js
@@ -1,5 +1,5 @@
const nodeFetch = require("node-fetch");
const fetchCookie = require("fetch-cookie");
const makeFetchCookie = require("fetch-cookie");
const cheerio = require("cheerio");
const logger = require("../logger");
const locations = require("../locations");
Expand Down Expand Up @@ -32,15 +32,16 @@ class BookingService {
constructor(region, numberOfPeople = 1, mock = false) {
this.region = region;
this.mock = mock;
this.fetch = (url, options) => {
options = options || {}
options.headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4844.52 Safari/537.36",
...options.headers || {}
}

return fetchCookie(nodeFetch)(url, options)
};
this.fetchInstance = makeFetchCookie(nodeFetch);
this.fetch = (url, options = {}) =>
this.fetchInstance(url, {
...options,
headers: {
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4844.52 Safari/537.36",
...(options.headers || {}),
},
});

this.numberOfPeople = numberOfPeople;
}
Expand Down

0 comments on commit ab51fbc

Please sign in to comment.