Skip to content
Snippets Groups Projects
init-tcl-stop-points.js 956 B
Newer Older
  • Learn to ignore specific revisions
  • // eslint-disable-next-line @typescript-eslint/no-var-requires
    const axios = require('axios');
    // eslint-disable-next-line @typescript-eslint/no-var-requires
    const path = require('path');
    // eslint-disable-next-line @typescript-eslint/no-var-requires
    require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
    
    axios
      .post('http://localhost:3000/api/auth/login', {
        email: 'admin@admin.com',
        password: process.env.USER_PWD,
      })
      .then((res) => {
        const config = {
          headers: { Authorization: `Bearer ${res.data.accessToken}` },
        };
        axios
          .get('http://localhost:3000/api/tcl/update', config)
          .then((res) => {
            console.log(`TCL stop points | statusCode: ${res.status}`);
          })
          .catch((error) => {
            console.error('Error in fetching TCL stop points');
            console.error(error);
          });
      })
      .catch((error) => {
        console.error('Error in auth');
        console.error(error);
      });