โš ๏ธ Warning: This post is over a year old, the information may be out of date.

๐Ÿ“ Hugo "GetJSON" now support HTTP Header

๐Ÿ“… | โฐ 1 minutes

TIL that hugo actually support custom HTTP headers to be use together with getJSON function which means you not anymore limited to just use or call API that have token=xxx on URL parameter anymore. Now you can use some header such as Authorization (example: Bearer, OAuth and more).

The implementation is quite simple just create a dictionary data and put the information inside and bind it together with getJSON as second parameter.

Example

Below is an example for my custom Hugo shortcode to get Malaysia forecast from MET API which require to send custom bearer Authorization on HTTP header for each request

Please take note, this feature only available for released hugo version 0.84.0 and above. Thanks for the fish!


๐Ÿ”€ Syndicated on:

Posted by: Robbi Nespu

Edit

Have some thoughts, discussion or feedback on this post?

๐Ÿ’ฌย Send me an email

What is webmention? How to send interactions!

Below you can find all of webmention with this page. Which means, you also can mentioned this URL on any website that support WebMention. Have you written a response to this post? Let me know the URL:

Do you use a website that don't have WebMention capabilities? You can just use Comment Parade!