Saving with JavaScript

Hello!

Is it possible to make my app to save text with JavaScript so that it’s accessible on all devices? Currently everything that it saves is only accessible on my phone.

Generally speaking yes but let me suggest that you explain a little about what you are trying to do because how can depend on how “all devices” and “accessible” is defined.

Yes, by all devices I meant my phone and computer. :slight_smile: I thought that when I wrote the saved text on my phone it would be visible in the same project when I opened it on my computer but it isn’t. That’s what I was wondering. I can only see my project’s saved text on the same device it was written.

If that is the case something is wrong. Are you saying that you log into Glitch from your phone and view your project and you see a file sitting there, one that you can read say in the editor? And then you log into Glitch from your computer, open the same project and you don’t see the file?

That can’t happen so I would drop into the terminal and check if you see the file listed in whatever folder you have it in. If you see it then perhaps simply typing refresh will bring the file into the editor.

I think they’re asking about building a site that maintains/syncs user data, not an issue with the glitch editor.

There’s no issue with the editor or the file. Both of them work fine. I created a function in the project that saves text so that when I launch the app I can write text to the text area. The text is then saved so the next time I launch the app the saved text is all there and it doesn’t disappear. But the saving only works on the same device it was written. If I launch the app on my phone and write text into the text area the text is saved and is still there when I launch the app again but not when I launch the same app on my computer. That’s what my question was about.

Yes! :slight_smile: I just want to know if it’s possible to save the text that I wrote into the text area in the launched app and it currently works only on the same device it was written.

Where is it saving the text? Any chance it isn’t written to a file and closed?

Here is the project and the JS code:

I’m just a beginner with JavaScript so I’m not sure if it’s saving it correctly.

You are writing your text to a cookie. They are not cross-browser things. You have to write to something neutral (like to a file on the server). Any device could read/write to or from that file via the server.

I see. Are there any good tutorials for that? I’m still browsing and I already got stuck on one. :smiley:

I am sure there are good tutorials and I know there are not so good and far to complicated ones also. The first thing you need to do is to define what it is you want your app to do. You don’t have to tell me but you do need to tell yourself or you can’t write it.

Notes just for yourself or can other people add notes too? Notes that are public/shared or private per person? Short long in length? Temporary “pick up groceries” or semi-permanent? The thing is they can be saved in memory or written to a text file or written to a database it all depends upon how these will be used.

You are fundamentally looking at a REST-based CRUD app. The client (browser) tells the server (your app on Glitch) to create, read, update and delete notes via GET and POST. The server “saves” them in whatever format you decide works for you.

I searched “write a note taking app in Node” and came up with several. You may even find a library that has most of it implemented. I didn’t watch these all the way through but the start seemed promising.

(this is multi-part)

(this has code and I think the second link is a video the guy did about it)

The “key” for you (in my opinion) is to separate the stuff you need from the stuff they decided to show. In the second case Mongo. There is no need to use Mongo to save notes but yes you can save notes in Mongo. You can save notes with other databases and you can save notes with no database at all.

So extract the “fundamentals” from the tutorials and apply them based upon what you want to do and the hassle the various solutions introduce. You don’t need an advanced math library to add a few numbers together :slight_smile:

Alright, thank you! I just assumed at first that it would as simple as that normal saving function that I did. I have to keep studying then! :smiley:

I don’t want you to spend too much time if your needs are simple. You can just use Node’s fs library to write to a file and read it back. That is fast and easy I just don’t know if your plan is just for you for for everyone one the site, etc.

Have fun