You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

strapiApiBuilder.js 358B

12345678910111213
  1. const api_url = process.env.REACT_APP_API_URL;
  2. export const strapiApiBuilder = (page, stringArray) => {
  3. const api = `${api_url}/api/${page}`;
  4. let query = '';
  5. stringArray.map((field, index) => {
  6. if (index === 0) query += `?populate[${index}]=${field}`;
  7. else {
  8. query += `&populate[${index}]=${field}`;
  9. }
  10. });
  11. return api + query;
  12. };