Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
10

Save Data Using JsonStore.io

hyperupcall
hyperupcall

Save Data Using JsonStore.io

The jsonstore.io website has been mentioned quite a bit recently. It provides a really easy way to store and retrieve data. It's perfect if you're trying to store non-sensitive, public data.

Using jsonstore.io is super easy. First, you have to visit https://www.jsonstore.io and copy your endpoint.

image

If you're unfamiliar, an "endpoint" is basically some URL where you can access some service. In this case, you're accessing the jsonstore.io service.

There are two main operations that I'm going to go over

  • retrieving data
  • storing data

Retrieving Data

To retrieve data, you can simply access the endpoint URL.

image

As you can see, there isn't much there. (Note that I'm using a Chrome Extension called "JSON Viewer" that makes JSON data more readable)

If you want to do this programmatically, simply send a GET request to the endpoint. In Node, you can use the Axios package to easily send a GET request.

let axios = require("axios"); // Retrieves data at the URL axios.get(url) .then(response => { let myData = response.data; console.log(myData); }) .catch(e => console.log(e));

As you can see, we get the same output!

image

Storing data

If you want to store some data, you just have to send a POST request to your endpoint. For example, if you are using Axios, you can do something like this:

// Stores data at the URL let myObject = { a: "alfa", b: "bravo", c: "charlie" }; axios.post(url, myObject);

That will send the following data:

image

A few people in the replit community made some packages to make the process a bit easier.

@TheDrone7
made a JavaScript package called async-jsonstore-io and
@leon332157
made a Python module called json-store-client. If you're feeling a bit adventurous, you can use those packages!

Storing your Endpoint in an Environment Variable

In the above examples, I assigned the endpoint to a variable directly, like this:

let url = "https://www.jsonstore.io/e3b92aa0c2566780a4ff0ef6aa74f99d66ea292ac017aa98243fbbac3d5d6d62";

However, that's really bad practice since anyone that opens up our repl can find the URL, and retrieve or store data without us knowing about it. We want to hide the URL. To do this, we can utilize .env files, which will hide the information.

image

For Node, there is a package called dotenv. It loads up the variables in the .env file as environment variables.

All you have to do is add a require statement for it.

require("dotenv").config(); console.log(process.env.ENDPOINT);

Now, to use your variable, you can access it as a property of process.env.

image

3 years ago

Voters

Comments

TopNew
3
Foster_Bryant
Foster_Bryant

How do I use this with python?

3 years ago
1
brittebaker
brittebaker

Well! hit the link you have mentioned above in a content but it landed me on a page where it had showed me a nasty 404 error. I just wanted to know about your services and there is absolutely no doubt that website like affordable essay writer Ireland to a such a great extent but it depends largely on the quality of content what you have to offer to reader.

7 months ago
1
mollthecoder
mollthecoder

If you want i can remove the dependency
But this was 2 years ago...

2 years ago
1
btecht
btecht

How do you use this with Java

3 years ago
1
HackermonDev
HackermonDev

@btecht
You send post request and get requests to your url with Java.

3 years ago
1
JordanDixon1
JordanDixon1

How do I use this with PHP?

3 years ago
1
HackermonDev
HackermonDev

@JordanDixon1
You send post request and get requests to your url with PHP.

3 years ago
1
JordanDixon1
JordanDixon1

@PDanielY
could you give me an example code?

3 years ago
1
JordanDixon1
JordanDixon1

@PDanielY
Oh ok. X3 Thanks anyway.

3 years ago
Load more