js: fix pays API request on older Edge and Safari

The /api/pays API requires user authentication. However older versions
of Edge and Safari don't transmit cookies by default during a
`fetch` request.

Use the `credentials: 'same-origin'` option explicitely to fix the
countries list.
This commit is contained in:
Pierre de La Morinerie 2021-09-30 13:13:57 +00:00
parent 7f588baa83
commit b2774ed2f6

View file

@ -1,5 +1,5 @@
import { QueryClient } from 'react-query';
import { isNumeric } from '@utils';
import { getJSON, isNumeric } from '@utils';
import { matchSorter } from 'match-sorter';
const API_EDUCATION_QUERY_LIMIT = 5;
@ -73,7 +73,7 @@ async function defaultQueryFn({ queryKey: [scope, term] }) {
let paysCache;
async function getPays() {
if (!paysCache) {
paysCache = await fetch('/api/pays').then((response) => response.json());
paysCache = await getJSON('/api/pays', null);
}
return paysCache;
}