Closed watchoutfreedom closed 2 years ago
I added a test branch to api call, please if you can give your thoughts
@albjeremias can you tell @Andresargote how to receive networks data with the axios calll. I did with the button data andd got an empty array but I suppose it's normal. thanks
here!
const resFilter = client.get('/networks/find').query({
filter: `{
"where": {
"id": 3
},
"include": [
{
"relation": "buttons",
"scope": {
"limit": "1"
}
}
]
}`});
in the backend im using: https://github.com/visionmedia/superagent which is very similar to axios.
the response of the backend will be something like:
[{
name: 'Perritos en adopcion',
id: 3,
url: 'net/url',
avatar: 'image/url.png',
description: 'Net for animal rescue',
privacy: 'publico',
place: 'Livorno, Italia',
latitude: 43.33,
longitude: 43.33,
radius: 240,
tags: ['Animales', 'Perritos', 'Adopcion'],
buttonsTemplate: [],
role: 'admin',
buttons: [
{
id: 1,
name: 'button name',
type: 'exchange',
tags: ['onetag'],
description: 'description of da button',
latitude: 3.12321321,
longitude: 5.32421321
}
]
}]
You can start the backend with a test database, if you do:
$ cp data/db.ini.json data/db.json
@watchoutfreedom this example also might help to get ideas: https://loopback.io/doc/en/lb4/Building-frontend-angular-application.html
I have sent a proposal of a way of managing backend call:
https://github.com/helpbuttons/hb-front/pull/25
I have finished the basic state module that I send some time ago, and made a possible implementation of backend communication and global state use.
This is not the only possible way of doing this, there are many others. For example, I have used rxjs observables for the async fetching of data, but also promises could have been used.
I hope that is autoexplicative, but ask me any doubts.
I included examples for button and network and merged it 👍
test communication between back and front