Authentication
Learn how to authenticate with Countercyclical's API.
Last updated
import axios, { AxiosResponse } from 'axios';
import { NextFunction, Request, Response, Router } from 'express';
const router = Router();
const apiKey = process.env.COUNTERCYCLICAL_API_KEY;
const countercyclicalAxiosInstance = axios.create({
baseURL: 'https://api.countercyclical.io',
params: {
apiKey: apiKey,
},
});
router.get('/v1/investments', async (req: Request, res: Response, next: NextFunction) => {
try {
await countercyclicalAxiosInstance
.get('/v1/investments', { params: { limit: 6 } })
.then((apiResponse: AxiosResponse) => {
if (apiResponse.status === 200) {
return res.send(apiResponse.data);
}
});
} catch (error) {
console.error(error);
}
});