28 lines
967 B
JavaScript
28 lines
967 B
JavaScript
const BASE = 'http://localhost:3002';
|
|
const PID = 'b1b5884e-ba85-4d8f-9a92-e524603587a0';
|
|
|
|
async function main() {
|
|
const login = await fetch(`${BASE}/api/auth/login`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ password: '620f4c96' })
|
|
});
|
|
const { token } = await login.json();
|
|
const auth = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` };
|
|
|
|
// Test: send entry with different payload
|
|
for (const body of [
|
|
{ title: 'test1', repo_url: 'https://example.com/r1.git' },
|
|
{ title: 'test2', repo_url: 'https://example.com/r2.git', category_tag: '' },
|
|
]) {
|
|
const r = await fetch(`${BASE}/api/projects/${PID}/entries`, {
|
|
method: 'POST', headers: auth,
|
|
body: JSON.stringify(body)
|
|
});
|
|
const text = await r.text();
|
|
console.log(`body=${JSON.stringify(body)} status=${r.status} response=${text.slice(0, 100)}`);
|
|
}
|
|
}
|
|
|
|
main().catch(console.error);
|