-
Notifications
You must be signed in to change notification settings - Fork 0
Setting Up A Simple JSON API Endpoint
In the Getting Started page , we saw that we can create a settings.json file to setup how we want out system to behave like.
The simplest settings.json file content looks like this
{
"config": [{
"apiport": 8891
}]
}
This creates a server available at port 8891 on the local host ie http://localhost:8891/
This is based on the fantastic gulp-json-server library https://github.com/GrafGenerator/gulp-json-server
You can setup what you'll find when you get to a certain path. For example to set up an api end point http://localhost:8891/api/GetProducts3, the settings will look like this
{
"config": [{
"apiport": 8891,
"routes": [{
"route": "/api/GetProducts3"
}]
}]
}
But to setup a reference to the data to return at the end point , settings.json becomes
{
"config": [{
"apiport": 8891,
"routes": [{
"route": "/api/GetProducts3",
"data": "mydata"
}]
}]
}
In this case the reference to the data we want to return is "mydata" But to actually provide what data to return, settings.json becomes
{
"config": [{
"apiport": 8891,
"datasource": [{
"mydata": [{
"hey": "whatpp"
}]
}],
"routes": [{
"route": "/api/GetProducts3",
"data": "mydata"
}]
}]
}
Now we have, in doing so, specified that when we hit http://localhost:8891/api/GetProducts3, the json data
[{
"hey": "whatpp"
}]
which just happens to be a list of objects specified in , will, indeed, be returned
Next >> https://github.com/getbackender/backender/wiki/Setting-Up-Proxy