Web
Storybook JS: 'Cannot GET /'
· Reading time: ~1 minute(s) (151 words) programming web javascript storybook reactWhen you run storybook locally, you might encounter the error ‘Cannot GET /’ when browsing to localhost:6006.
The general advice given online is to delete all node modules for your project and re-install the packages using your preferred package manager. However, this doesn’t always solve the problem and I was in this position just a moment ago.
Luckily, in the Storybook CLI docs, there is an argument --no-manager-cache which says that it will disable the Storybook manager caching mechanism. They recommend not using this every time you run it, but it’ll help when you need to refresh the Storybook UI, such as when editing themes etc.
Reduce a large JSON object down to only what you need
· Reading time: ~2 minute(s) (393 words) programming javascript json webSometimes you need to use an API that returns a large payload, but you may only need to use a small number of fields from that payload. Rather than try storing that data, or hand-balling the data yourself, there is an alternative solution.
In various other languages, such as C#, you can serialise and deserialise data and strip out what data you don’t want (by not declaring those properties in the models). This post explains how you can achieve the same thing in JavaScript with a little help from a pre-defined model, and some recursion:
(Continue reading)Stop your font sizes differing between Landscape and Portrait mode on iOS
· Reading time: ~1 minute(s) (56 words) programming css web iosHave you ever had the problem where you’re styling some content but when you rotate the device to change between landscape and portrait modes on an iOS device, the font size changes?
The simplest way to resolve it is to include this in one of your primary css rules such as html or body:
-webkit-text-size-adjust: 100%;
View Hugo served content on another device on network
· Reading time: ~1 minute(s) (190 words) post gohugo.io webWhen you want to view content served by a locally running instance of Hugo on another device, you have to specify a few extra things so it will work correctly.
When you start the Hugo server locally, it will show the following output:
$ hugo server -w
...
(some output omitted here for brevity)
...
Web Server is available at //localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
Because it’s bound to your localhost IP, you can’t just open port 1313 on your computer via a firewall and access Hugo from another device. You have to bind Hugo to the network IP instead (To find out the IP, try ipconfig on Windows or ip a on Linux).