mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 22:46:13 +00:00
pass options in search endpoint
This commit is contained in:
parent
36326a2a70
commit
143f8f43fa
@ -4,8 +4,8 @@
|
|||||||
*
|
*
|
||||||
* @id integer - id of accompanyingCourse
|
* @id integer - id of accompanyingCourse
|
||||||
*/
|
*/
|
||||||
let getAccompanyingCourse = (id) => { //tmp
|
const getAccompanyingCourse = (id) => {
|
||||||
const url = `/api/1.0/person/accompanying-course/${id}.json`
|
const url = `/api/1.0/person/accompanying-course/${id}.json`;
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) { return response.json(); }
|
if (response.ok) { return response.json(); }
|
||||||
@ -21,8 +21,8 @@ let getAccompanyingCourse = (id) => { //tmp
|
|||||||
* @person_id integer - id of person
|
* @person_id integer - id of person
|
||||||
* @method string - POST or DELETE
|
* @method string - POST or DELETE
|
||||||
*/
|
*/
|
||||||
let postParticipation = (id, person_id, method) => {
|
const postParticipation = (id, person_id, method) => {
|
||||||
const url = `/api/1.0/person/accompanying-course/${id}/participation.json`
|
const url = `/api/1.0/person/accompanying-course/${id}/participation.json`;
|
||||||
return fetch(url, {
|
return fetch(url, {
|
||||||
method: method,
|
method: method,
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -1,12 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Build query string with query and options
|
||||||
|
*/
|
||||||
|
const parametersToString = ({ query, options }) => {
|
||||||
|
let types ='';
|
||||||
|
options.type.forEach(function(type) {
|
||||||
|
types += '&type[]=' + type;
|
||||||
|
});
|
||||||
|
return 'q=' + query + types + '&uniq=' + options.uniq;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Endpoint chill_person_search
|
* Endpoint chill_person_search
|
||||||
* method GET, get a list of persons
|
* method GET, get a list of persons
|
||||||
*
|
*
|
||||||
* @query string - the query to search for
|
* @query string - the query to search for
|
||||||
*/
|
*/
|
||||||
let searchPersons = ({ query, options }) => {
|
const searchPersons = ({ query, options }) => {
|
||||||
console.log('options', options);
|
let queryStr = parametersToString({ query, options });
|
||||||
let url = `/fr/search.json?name=person_regular&q=${query}`;
|
let url = `/fr/search.json?name=person_regular&${queryStr}`;
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) { return response.json(); }
|
if (response.ok) { return response.json(); }
|
||||||
@ -21,9 +32,9 @@ let searchPersons = ({ query, options }) => {
|
|||||||
* NOTE: this is a temporary WIP endpoint, return inconsistent random results
|
* NOTE: this is a temporary WIP endpoint, return inconsistent random results
|
||||||
* @query string - the query to search for
|
* @query string - the query to search for
|
||||||
*/
|
*/
|
||||||
let searchPersons_2 = ({ query, options }) => {
|
const searchPersons_2 = ({ query, options }) => {
|
||||||
console.log('options', options);
|
let queryStr = parametersToString({ query, options });
|
||||||
let url = `/api/1.0/search.json?q=${query}`
|
let url = `/api/1.0/search.json?${queryStr}`;
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) { return response.json(); }
|
if (response.ok) { return response.json(); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user