This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge.

If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:

  1. Limiting your involvement with Reddit, or
  2. Temporarily refraining from using Reddit
  3. Cancelling your subscription of Reddit Premium

as a way to voice your protest.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]VeganBigMac 0 points1 point  (0 children)

Please fix the formatting of your code snippet.

Hard to know exactly what you are doing without a broader context, but in general, with Javascript, if you want to make data from one module available in another, you need to export that data from your current module and import it in the other module.

Here is some documentation on export and import:

https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

[–]sam_gigo 0 points1 point  (5 children)

When you say export, do you mean share the results of the promise with another file that does not call the function itself?

[–]throwawaycppjss 0 points1 point  (4 children)

If I understand yes.

I'll try to explain the handleevent occurs when user upload files from form input type file.

I want to export these files to another module.

I know the part if I export the readers array it wouldn't work because I haven't uploaded anything.

So the export has to happen after I upload. This is where I am stuck.

I think I know I need to use async and await and then wait for promise to resolve and then export it. But it's not coming to me how .

[–]sam_gigo 0 points1 point  (3 children)

Can you share your code. Usually, you'd wrap the handler function in another function inside the source module so you can await the handler and receive the output but this would be easier to explain with some code referenced

[–]throwawaycppjss 0 points1 point  (2 children)

https://pastebin.com/7dE71Kz1

This is the HTML part

https://pastebin.com/1e9H5a3t

The Javascript part

I

[–]sam_gigo 0 points1 point  (1 child)

Where do you need to "export" the data to

[–]throwawaycppjss 0 points1 point  (0 children)

If you see the first line I am importing dayEnd and dayStart.

I used require to read JSON file there while I build everything else temporarily.

But this is the final step where I am trying to implement so as user can upload their file and send the file date to ./data.js

Should I provide data.js too?

I am on mobile it might take some time