Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to pass the contents of fetched data using CORS proxy to another function #45

Open
IshaGupta18 opened this issue Jun 12, 2019 · 1 comment
Labels
bug Something isn't working gsoc help wanted Extra attention is needed summer of code

Comments

@IshaGupta18
Copy link
Collaborator

To fetch data from a remote file #35 , I had to implement a CORS proxy for it, and it is able to fetch the data from the remote CSV file, however, I am unable to pass it on to another function, but just print it in the console. #42 has the code for it, I have left a review in the PR against the code snippet. Let's resolve this really quickly

image

@jywarren @namangupta01 @gauravano @rexagod

@IshaGupta18 IshaGupta18 added bug Something isn't working help wanted Extra attention is needed labels Jun 12, 2019
@rexagod
Copy link
Member

rexagod commented Jun 13, 2019

handleFileSelectremote(val){
const proxyurl = "https://cors-anywhere.herokuapp.com/";
const url = val;
fetch(proxyurl + url)
.then(response => response.text())
.then(contents => console.log(contents))
.catch(() => console.log("Can’t access " + url + " response. Blocked by browser?")) ;
console.log(this.csvFile,"remote file");
}

 handleFileSelectremote(val, callback){ 
     const proxyurl = "https://cors-anywhere.herokuapp.com/";  
     const url = val; 
     fetch(proxyurl + url) 
     .then(response => response.text()) 
     .then(contents => callback(contents))
     .catch(() => console.log("Can’t access " + url + " response. Blocked by browser?")) ; 
 } 

@IshaGupta18 Try doing this. Also, do we think that it might be more useful to pass the error object inside the catch arrow fn, for a better description (since there could be scenarios where the request fails and isn't actually blocked by the browser)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working gsoc help wanted Extra attention is needed summer of code
Projects
None yet
Development

No branches or pull requests

2 participants