DEV Community

loading...
Cover image for I have no idea what I'm doing, but here Goes #2 Yay! Json!!

I have no idea what I'm doing, but here Goes #2 Yay! Json!!

jamonjamon profile image Jaimie Carter ・2 min read

Well folks if you've been playing along, the goal here is to further make life easier with tWC2k (the Work Chaser 2000!) by automating the never ending treadmill that afflicts all freelancers - the work hustle, thus freeing up to for me to surf and drink beer with my friends. "A noble goal!" I hear you cry. Yes, yes it is.

So, after a busy weekend of work (cue the violins again), I sat down this morning and thought, "how will this actually work?" In the last post I thought maybe the right way to go would be to build an express app, then test the end points with Postman - and then connect that to the Google Calendar API. But, if you think about it (there it goes again, this whole 'thinking' thing... shudder), maybe I need to see if I can get stuff out of the Google API first. Probably a good idea not to put the horse before the cart, right? Let's get something, anything out of a Google Calendar, first. Fine. Now, that's all great, but how does one do that? Ah. Lightbulb. One could ask Google, I suppose? (I know, it's bordering on genius again) It turns out there's a npm script you run and hey-presto! There's your connection to a Calendar with the last 10 events listed. Even a dullard like me managed to do it.

The thing I managed to get working is on my GitHub. It manages to pull the last 20 events from a Google calendar and display them as a json object in the browser. The little bit of code that is there is like my house - a total mess, I apologise in advance, if you're going to look at it.

Next up: to use this json to find the holes in my calendar and make a new json with available dates.

Thoughts?

Discussion (7)

pic
Editor guide
Collapse
peterwitham profile image
Peter Witham

I've found that if I search long enough and with enough trial and error, there is usually an API for what I'm looking to do and a script to make it happen. It's always better if all you need to do is the plumbing between the API and what you want to do with that return.

Collapse
jamonjamon profile image
Jaimie Carter Author

True. But where's the fun in that?

Collapse
peterwitham profile image
Peter Witham

So very true, we all gotta have some fun with these things to keep it interesting.

Thread Thread
jamonjamon profile image
Jaimie Carter Author

Yeah, it's weird. I honestly enjoy going through the process of trying to figure out how to do this stuff.

Collapse
jamonjamon profile image
Jaimie Carter Author

Great advice. I'll implement all those points. The debugging one in particular - the is like black magic to me, so I guess I need to demystify it. The sooner the better. Thanks so much for the advice.

Collapse
jamonjamon profile image
Jaimie Carter Author

WOAH! I just started using the debugger in vscode! It's blown my mind. Why haven't I learnt to use this already?