Optional config: FejConfigConfiguration for the instance
A new Fej instance
import { createFej } from 'fej';
const api = createFej();
const response = await api.fej('https://api.example.com/users');
const api = createFej({
retry: {
attempts: 3,
delay: 1000,
backoff: 'exponential',
},
errorTransforms: [
async (error, ctx) => {
console.error(`Request failed: ${ctx.request.url}`);
return error;
},
],
});
const userApi = createFej({ retry: { attempts: 5 } });
const paymentApi = createFej({ retry: { attempts: 10 } });
// Each instance has independent configuration and middleware
Create a new Fej instance with configuration
Factory function for creating isolated Fej instances with custom configuration. This is the recommended way to use Fej in v2.