1
1
import fetch from 'node-fetch' ;
2
2
3
3
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 }}"}' ;
5
6
6
7
class User {
7
8
login ( email , password ) {
@@ -37,7 +38,6 @@ class User {
37
38
}
38
39
39
40
async function bundestagProcedures ( ) {
40
- const query = '{"query": "{procedures(type: PREPARATION, pageSize: 1) { title abstract }}"}' ;
41
41
return await fetch ( bundestagGraphqlUrl , {
42
42
method : 'post' ,
43
43
body : query ,
@@ -56,16 +56,20 @@ async function main() {
56
56
let user = new User ( ) ;
57
57
await user . login ( '[email protected] ' , '1234' ) ;
58
58
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
+ }
69
73
}
70
74
71
75
main ( ) ;
0 commit comments