adapt api endpoint, resolve id parameter passed in api functions

This commit is contained in:
2021-05-10 10:43:28 +02:00
parent 43f3270171
commit dcd1856ebb
3 changed files with 34 additions and 28 deletions

View File

@@ -1,16 +1,12 @@
const
locale = 'fr',
format = 'json'
;
/*
* Endpoint chill_person_search, method GET, get a list of persons
* Endpoint chill_person_search
* method GET, get a list of persons
*
* @query string - the query to search for
*/
let searchPersons = ({ query, options }) => {
console.log('options 2', options);
let url = `/${locale}/search.${format}?name=person_regular&q=${query}`;
console.log('options', options);
let url = `/fr/search.json?name=person_regular&q=${query}`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
@@ -18,4 +14,22 @@ let searchPersons = ({ query, options }) => {
});
};
export { searchPersons };
/*
* Endpoint v.2 chill_main_search_global
* method GET, get a list of persons and thirdparty
*
* NOTE: this is a temporary WIP endpoint, return inconsistent random results
* @query string - the query to search for
*/
let searchPersons_2 = ({ query, options }) => {
console.log('options', options);
let url = `/api/1.0/search.json?q=${query}`
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
export { searchPersons, searchPersons_2 };