summaryrefslogtreecommitdiff
path: root/src/main.v
blob: 4775e50df5adf0ae2458f9d5d0c098f6fe3b6359 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module main
import net.http
import json
import time
struct ResponseStruct {
	id int
	text string
}

struct PostResp {
	success string
}

struct RequestStruct {
	date time.Time
	journal_data string
}

fn main() {
	println('Hello World!')
	payload := json.encode(RequestStruct{date: time.now(), journal_data: 'My First Journal'})
	resp := http.post_json('http://localhost:3000', payload) or {
		println('Failed to FETCH API')
		return
	}

	resp_data := json.decode(PostResp, resp.body) or {
							 println('Failed to Decode the data')
							 return
						 }
  println(resp_data )

}