Skip to content

Commit 6265a2e

Browse files
committed
Use local democracy server
instead of local bundestag.io server
1 parent a7dde1a commit 6265a2e

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

index.mjs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import fetch from 'node-fetch';
22

33
const hcBackendUrl = 'http://localhost:3030'
4-
const bundestagGraphqlUrl = 'https://democracy.bundestag.io/graphql'
4+
const bundestagGraphqlUrl = 'http://localhost:3000/graphql'
5+
const query = '{"query": "{procedures(type: PREPARATION) { title abstract }}"}';
56

67
class User {
78
login(email, password) {
@@ -37,7 +38,6 @@ class User {
3738
}
3839

3940
async function bundestagProcedures(){
40-
const query = '{"query": "{procedures(type: PREPARATION, pageSize: 1) { title abstract }}"}';
4141
return await fetch(bundestagGraphqlUrl, {
4242
method: 'post',
4343
body: query,
@@ -56,16 +56,20 @@ async function main() {
5656
let user = new User();
5757
await user.login('[email protected]', '1234');
5858
const procedures = await bundestagProcedures();
59-
const contribution = {
60-
title: procedures[0].title,
61-
content: procedures[0].abstract,
62-
contentExcerpt: procedures[0].abstract,
63-
type: "post",
64-
language: "de",
65-
categoryIds: ["5ac7768f8d655d2ee6d48fe4"] // democracy-politics
66-
}
67-
const response = await user.contribute(contribution);
68-
console.log(response);
59+
if (procedures.length > 0){
60+
const contribution = {
61+
title: procedures[0].title,
62+
content: procedures[0].abstract,
63+
contentExcerpt: procedures[0].abstract,
64+
type: "post",
65+
language: "de",
66+
categoryIds: ["5ac7768f8d655d2ee6d48fe4"] // democracy-politics
67+
}
68+
const response = await user.contribute(contribution);
69+
console.log(response);
70+
} else {
71+
console.log("No procedures found!");
72+
}
6973
}
7074

7175
main();

0 commit comments

Comments
 (0)