List of useful npx (NPM Package Runner) commands.
Using NPX we can execute/run node binaries without the need to install it locally or globally.
List of useful npx (NPM Package Runner) commands.
Using NPX we can execute/run node binaries without the need to install it locally or globally.
const chromeLauncher = require('chrome-launcher'); | |
const axios = require('axios'); | |
const puppeteer = require('puppeteer'); | |
(async () => { | |
// Initializing a Chrome instance manually | |
const chrome = await chromeLauncher.launch({ | |
chromeFlags: ['--headless'] | |
}); | |
const response = await axios.get(`http://localhost:${chrome.port}/json/version`); |
If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:
let
and const
statements. For the purposes of the React documentation, you can consider them equivalent to var
.class
keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this
in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/JavThis guide is specific to getting LND 0.5-beta and Bitcoind running on Ubuntu 16.04 LTS for mainnet. It is aging rapidly and includes steps not necessary on newer versions of LND. As of April 2021 it is very out of date for bitcoind. As of December 2021 it is outdated for LND too.
Original installation guide:
This guide is broken into the following sections:
bitcoind
and set to start automatically// In JavaScript, constructors can only be synchronous right now. This makes sense | |
// from the point of view that a constructor is a function that returns a newly | |
// initialized object. | |
// | |
// On the other hand, it would sometimes be very handy, if one could have async | |
// constructors, e.g. when a class represents a database connection, and it is | |
// desired to establish the connection when you create a new instance. | |
// | |
// I know that there have been discussions on this on StackOverflow & co., but | |
// the so-far mentioned counter arguments (such as: doesn't work as expected |
$ curl --help | |
Usage: curl [options...] <url> | |
--abstract-unix-socket <path> Connect via abstract Unix domain socket | |
--alt-svc <file name> Enable alt-svc with this cache file | |
--anyauth Pick any authentication method | |
-a, --append Append to target file when uploading | |
--basic Use HTTP Basic Authentication | |
--cacert <file> CA certificate to verify peer against | |
--capath <dir> CA directory to verify peer against | |
-E, --cert <certificate[:password]> Client certificate file and password |
I really liked @tjvantoll article Handling Failed HTTP Responses With fetch(). The one thing I found annoying with it, though, is that response.statusText
always returns the generic error message associated with the error code. Most APIs, however, will generally return some kind of useful, more human friendly message in the body.
Here's a modification that will capture this message. The key is that rather than throwing an error, you just throw the response and then process it in the catch
block to extract the message in the body:
fetch("/api/foo")
.then( response => {
if (!response.ok) { throw response }
return response.json() //we only get here if there is no error
})