Spark core dev Code call Nodejs API?

I want to dev code to get data from server with Nodejs APi
Data result = Json format

It is possible or not .

if possible , I would like to Learn more

Sample or something to help me understand.

Have you tried looking in the docs? There’s a section there called “SparkJS”, which is a javascript library. You can use that with nodejs, but also in the browser directly. There are even examples included.

Concept me

Spark core

var Product_list = [
    {
        "id": 1,
        "product_barcode": "21312313"
    },
    {
        "id": 2,
        "product_barcode": "13123123"
    },
    {
        "id": 3,
        "product_barcode": "45646456"
    },
    {
        "id": 4,
        "product_barcode": "54353453"
    },
    {
        "id": 5,
        "product_barcode": "45677737"
    }
];

get_price_api [ Nodejs ]
Wait data from Spark core post json syntax to api
and return son format to spark core

var Return_Product_list = [
    {
        "id": 1,
        "product_name": "product1",
        "price": 20
    },
    {
        "id": 2,
        "product_name": "product2",
        "price": 12
    },
    {
        "id": 3,
        "product_name": "product3",
        "price": 20
    },
    {
        "id": 4,
        "product_name": "product4",
        "price": 17
    },
    {
        "id": 5,
        "product_name": "product5",
        "price": 35
    }
];

I’ve edited your post to properly format the code. Please check out this post, so you know how to do this yourself in the future. Thanks in advance! ~Jordy

I think I misunderstood the question the first time. If you’re looking to retrieve data from a server, you could use the HTTP() library to make requests. It’s included in the libraries inside the web IDE. Perhaps you could even take a look at webhooks, also mentioned in the docs.

1 Like