{"repo":"r17x/fetch.macro","free":true,"listed":false,"github":"https://github.com/r17x/fetch.macro","clone":"git clone https://github.com/r17x/fetch.macro.git","description":"Allows you to build fetcher function by URL at compile-time.","language":"Nix","stars":33,"topics":["babel-plugin-macros","fetch","javascript","create-react-app","babel-plugin","webpack","hacktoberfest","nextjs","swc-plugin","vite-plugin"],"license":"MIT","category":"saas-starters-boilerplates","readme_excerpt":"fetch.macro Allows you to build fetcher function by URL at compile-time. f(\"/api/ping\") ↓ ↓ ↓ ↓ ↓ ↓ (opts) = fetch(\"/api/ping\", opts) Usage • API • Contributors --- Usage [\\[Back to the Table of Contents\\] ↑](#toc) Simply install and configure babel-plugin-macros and then use fetch.macro . Some project that build with create-react-app doesn't need extra setup for babel-plugin-macros . SWC 🚧 [Under Development] This is section for using fetch.macro as swc-plugin. You can also use fetch.macro in a swc-based project (e.g: Next.js) by using the SWC plugins. Due to how the plugins loaded, you have to pass rootDir option pointing to the root directory of your project (where your node modules directory lives). Typically it's enough to pass \\ \\ dirname. Vite To be able to use these macros in your Vite project, you only need install vite-plugin-babel-macros and add some configuration in vite.config.js . And it just work. $ npm i -D vite-plugin-babel-macros Example Basic Run one of the following command inside your project directory to install the package: $ npm i fetch.macro or $ yarn add fetch.macro Given the following Input : Babel will produce the following Output : It also works as a tagged template literal: That will produce the same output as the function version. Nested Given the following Input : Babel will produce the following Output : API default It will be produce a code for fetch function with URL by input and return response that need to be manual handle the response. I","default_branch":null,"files":null,"tree":[],"storefront":"/r/r17x","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/r17x/fetch.macro/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}