Discover how to integrate v0 with Time Doctor using our step-by-step guide. Learn setup tips, best practices, and troubleshooting advice for seamless time tracking.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
package.json file and add the following dependency to include axios for HTTP requests:
{
"name": "v0-project",
"version": "1.0.0",
"dependencies": {
"axios": "^0.27.2"
// add other dependencies here if needed
}
}
TimeDoctorService.ts. For instance, if you have a folder structure, place it inside a new folder named /services.TimeDoctorService.ts:
import axios, { AxiosInstance } from 'axios';
interface TimeDoctorConfig {
apiToken: string;
companyId: number;
}
class TimeDoctorService {
private api: AxiosInstance;
private config: TimeDoctorConfig;
constructor(config: TimeDoctorConfig) {
this.config = config;
this.api = axios.create({
baseURL: 'https://webapi.timedoctor.com/v1.0',
headers: {
'Authorization': Bearer ${this.config.apiToken},
'Content-Type': 'application/json'
}
});
}
// Start the timer for a specific task or project
public async startTimer(taskId: number): Promise {
try {
const response = await this.api.post('/start', {
company_id: this.config.companyId,
task_id: taskId
});
return response.data;
} catch (error) {
console.error('Error starting timer:', error);
throw error;
}
}
// Stop the running timer
public async stopTimer(): Promise {
try {
const response = await this.api.post('/stop', {
company_id: this.config.companyId
});
return response.data;
} catch (error) {
console.error('Error stopping timer:', error);
throw error;
}
}
// Example: Fetch task/project details
public async getTaskDetails(taskId: number): Promise {
try {
const response = await this.api.get(/tasks/${taskId}, {
params: { company_id: this.config.companyId }
});
return response.data;
} catch (error) {
console.error('Error fetching task details:', error);
throw error;
}
}
}
export default TimeDoctorService;
main.ts or app.ts).
import TimeDoctorService from './services/TimeDoctorService';
// Replace with your actual Time Doctor API token and company ID
const timeDoctorConfig = {
apiToken: 'YOURTIMEDOCTORAPITOKEN',
companyId: 123456
};
const timeDoctorService = new TimeDoctorService(timeDoctorConfig);
// Example usage: Starting a timer for a task with ID 7890
async function startTaskTimer() {
try {
const startResponse = await timeDoctorService.startTimer(7890);
console.log('Timer started:', startResponse);
} catch (error) {
console.error('Failed to start timer:', error);
}
}
// Example usage: Stopping the timer
async function stopTaskTimer() {
try {
const stopResponse = await timeDoctorService.stopTimer();
console.log('Timer stopped:', stopResponse);
} catch (error) {
console.error('Failed to stop timer:', error);
}
}
// Call the functions according to your application logic,
// such as based on user action or specific events.
config.ts) and include the following:
export const TIMEDOCTORCONFIG = {
apiToken: process.env.TIMEDOCTORAPITOKEN || 'YOURTIMEDOCTORAPI_TOKEN',
companyId: Number(process.env.TIMEDOCTORCOMPANY_ID) || 123456
};
import { TIMEDOCTORCONFIG } from './config';
import TimeDoctorService from './services/TimeDoctorService';
const timeDoctorService = new TimeDoctorService(TIMEDOCTORCONFIG);
startTaskTimer() and stopTaskTimer() from your application’s UI or logic to ensure that requests are sent to Time Doctor correctly.When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.