Discord bot
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

25 lignes
450 B

  1. const createFetchClient = ({ baseURL, headers: baseHeaders = {} }) => {
  2. return async ({
  3. method = 'GET',
  4. url,
  5. query = undefined,
  6. headers = {},
  7. body = undefined,
  8. }) => {
  9. const theURL = new URL(url, baseURL)
  10. if (query) {
  11. theURL.search = new URLSearchParams(query).toString()
  12. }
  13. return fetch(theURL.toString(), {
  14. method,
  15. body,
  16. headers: {
  17. ...baseHeaders,
  18. ...headers,
  19. }
  20. })
  21. }
  22. }
  23. export default createFetchClient