// Test the project-tasks API endpoints async function testAPI() { const baseURL = "http://localhost:3000"; console.log("Testing project-tasks API endpoints...\n"); try { // Test 1: Check if users endpoint exists console.log("1. Testing /api/project-tasks/users:"); const usersResponse = await fetch(`${baseURL}/api/project-tasks/users`); console.log("Status:", usersResponse.status); if (usersResponse.ok) { const users = await usersResponse.json(); console.log("Users found:", users.length); console.log("First user:", users[0]); } else { const error = await usersResponse.text(); console.log("Error:", error); } // Test 2: Try to create a task (this will fail without auth, but let's see the response) console.log("\n2. Testing POST /api/project-tasks:"); const taskData = { project_id: 1, task_template_id: 1, priority: "normal", }; const createResponse = await fetch(`${baseURL}/api/project-tasks`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(taskData), }); console.log("Status:", createResponse.status); const responseText = await createResponse.text(); console.log("Response:", responseText); } catch (error) { console.error("Error testing API:", error.message); } } testAPI();