Skip to content

Commit

Permalink
proxy support added
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalpanchal committed May 18, 2019
1 parent bd10b68 commit c7304ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion dist/es5/lib/resources/medium/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ var sanitizedUsername = function sanitizedUsername(username) {

module.exports = {
get: async function get(from, size) {
var proxy = 'https://cors-anywhere.herokuapp.com/';
var mediumURL = 'https://medium.com/feed/' + sanitizedUsername(environment().medium.username);
return axios.get(mediumURL).then(function (response) {
return axios.get(proxy + mediumURL, {
headers: {
'x-requested-with': 'jj'
}
}).then(function (response) {
return mediumParser(response.data);
}).catch(function (error) {
console.log("TCL: error", error);
Expand Down
8 changes: 6 additions & 2 deletions lib/resources/medium/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ const sanitizedUsername = username => {

module.exports = {
get: async (from, size) => {
const proxy = environment().proxy || 'https://cors-anywhere.herokuapp.com/'
const mediumURL = `https://medium.com/feed/${sanitizedUsername(environment().medium.username)}`
return axios.get(mediumURL)
return axios.get(proxy + mediumURL, {
headers: {
'x-requested-with': 'axios'
}
})
.then(response => mediumParser(response.data))
.catch(error => {
console.log("TCL: error", error)
return error
})
}
Expand Down

0 comments on commit c7304ed

Please sign in to comment.