at.js - How do I combine first_name, last_name obtained from server into 'name'?
I'm using
https://github.com/ichord/At.js to fetch records from my server. My server sends me data in the following format:
- [{"id":1,"first_name":"Jack","last_name":"Welch"},
- {"id":2,"first_name":"Ines","last_name":"Ritchie"},
- {"id":3,"first_name":"Jaydon","last_name":"Wisoky"},
- {"id":4,"first_name":"Dannie","last_name":"Goldner"},
- {"id":5,"first_name":"Raymundo","last_name":"Mann"}]
However, at.js requires me to have the `[{ "id": 2, "name": "Jack Welch" }]` format. So far, I'm able to fetch data correctly from the server; but not being able to display it with the following configuration of at.js. Would really appreciate if someone could tell me how to get desired result.
- let config = {
- at: "@",
- limit: 10,
- displayTpl: "<li>${first_name} ${last_name}</li>",
- // delay time trigger At.js while typing. For example: delay: 400
- delay: 400,
- insertTpl: '<a data-id=${id} href="/users/">${atwho-at}${first_name}</a>',
- callbacks: {
- remoteFilter: function(query, callback) {
- axios.get('/users/', {
- params: {
- 's': query
- }
- }).then(function (response) {
- callback(response.data);
- })
- }
- }
- };