APIs
The APIs
field is one of the core parts of the ShapeRQ configuration. It's the only required option in createConfig
.
createConfig({
APIs: {}
});
What is APIs
?
APIs
?APIs
is a dictionary where each key is a name you assign to a backend server, and the value - dictionary of api params, baseUrl
, auth
, headers
.
When making a request with httpGet
, httpPost
, or any other function, you'll reference the API by its name — not by its URL.
setConfig({
APIs: {
Main: { baseUrl: "https://example.com" },
Second: { baseUrl: "https://example.io/" } ,
Useless: { baseUrl: import.meta.env.MyUrl }
}
});
There is no limit to the number of APIs you can define. However, it's highly recommended to keep the names short and meaningful, since:
You'll be using them in every request.
Use descriptive, consistent names — this improves readability and makes it easier to maintain large projects with multiple APIs.
Avoid using full URLs as baseUrl
Last updated