diff options
author | Indrajith K L | 2023-08-09 03:22:12 +0530 |
---|---|---|
committer | Indrajith K L | 2023-08-09 03:22:12 +0530 |
commit | af7ae10020cb6092f0491435ba43f3c09da663a4 (patch) | |
tree | 8cd5d96ca99cf678f4158b74966588c0f051ed09 /src | |
download | Journlr Frontend-af7ae10020cb6092f0491435ba43f3c09da663a4.tar.gz Journlr Frontend-af7ae10020cb6092f0491435ba43f3c09da663a4.tar.bz2 Journlr Frontend-af7ae10020cb6092f0491435ba43f3c09da663a4.zip |
* Working Post API integrated
Diffstat (limited to 'src')
-rw-r--r-- | src/main.v | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main.v b/src/main.v new file mode 100644 index 0000000..4775e50 --- /dev/null +++ b/src/main.v @@ -0,0 +1,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 ) + +} |