Yes!!! I think my test finally worked
Discussion
And what are you testing?
It actually didn’t work. Works way better than before though 😂
I have a nodejs file that is pulling the latest json from my notes that say “test”, and storing them in an api.
Everything works, but when a new note is populated, I have to visit the url of the api and refresh the page. Then it will update my website.
I need a way to refresh that page automatically. I could write a script on my pc that does it, but that doesn’t seem like the correct solution 🙃
If I follow…the notes are making it into your data store but the website is not updating automatically. That right?
Maybe set up a websocket between your site and your data store? Or you could go old school and have the page poll the api periodically.
Yeah basically. I’m thinking about websockets, but it’s such a simple but weird bug. Page polling is what I originally thought I’d have to do, but websockets might be better long term
Is the web browser caching your api url response?
If you use the dev tools and disable web page caching does it still do that?
I have caching turned off. It’s weird because when I refresh the api page, it works on several browsers.
It’s opening the relays every 30 seconds and checking for a new note. So I can have the api up on Safari, and check the website on Chrome. If I refresh the page on Safari, then Chrome will get updated too.
Instead of connecting to relays every 30 seconds, can you connect to them over websockets. Probably less overhead that way.
I know #[4] is working on NDK (Nostr Dev Kit) which might help in these situations. Don’t know many details about it yet though.
Awesome, that might make my life easier. I’ll keep an eye out for it
It’s already out, needs better docs https://ndk.fyi
Check out ndk-cli for very simple examples
Awesome, just read through the readme.md. Looks like it’s simple to use and already does a ton.
yeah, it's what I'm using for all my projects; definitely ready for use
Bookmarking.
I have a few projects in queue and I’ll be doing some reading and prototyping over the next week.
#[4] awesome work as always!
awesome!
join here if you need some help!
https://www.nostrchat.io/channel/a6f436a59fdb5e23c757b1e30478742996c54413df777843e0a731af56a96eea
Why can’t you connect to the relay and run the request and leave it open?
If you do a request and pull the data after the “EOSE” message you’ll get new data coming in satisfying your query request.
I’m a little thick headed so just to try to visualize this. You have a nodejs “servlet” that’s doing these queries and then storing them for you to retrieve via an API call you invoke from a web browser?
I thought about leaving the relay open, but thought it might cause performance issues. I don’t know a whole lot about the nostr protocol. I’ll try that and see. I have to go to bed now though.
Goodnight and thanks for the help 🤙
Anytime.
Go read the NIPs and run a tool like Nostril (I think jb55 wrote it) to do some test events and queries.
It’s how I learned and had a lot of my aha moments.
Good night!