โ ๏ธ 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: Hugo