mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
Formatting JavaScript sample code.
This commit is contained in:
@@ -104,7 +104,7 @@ strictly follow the Node.js model as described in the
|
|||||||
|
|
||||||
For instance, we could have created the same request to 'github.com' as follows:
|
For instance, we could have created the same request to 'github.com' as follows:
|
||||||
|
|
||||||
```JavaScript
|
```javascript
|
||||||
const request = net.request({
|
const request = net.request({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
protocol: 'https:',
|
protocol: 'https:',
|
||||||
@@ -141,7 +141,7 @@ The `callback` function is expected to be called back with user credentials:
|
|||||||
* `username` String
|
* `username` String
|
||||||
* `password` String
|
* `password` String
|
||||||
|
|
||||||
```JavaScript
|
```javascript
|
||||||
request.on('login', (authInfo, callback) => {
|
request.on('login', (authInfo, callback) => {
|
||||||
callback('username', 'password')
|
callback('username', 'password')
|
||||||
})
|
})
|
||||||
@@ -150,7 +150,7 @@ request.on('login', (authInfo, callback) => {
|
|||||||
Providing empty credentials will cancel the request and report an authentication
|
Providing empty credentials will cancel the request and report an authentication
|
||||||
error on the response object:
|
error on the response object:
|
||||||
|
|
||||||
```JavaScript
|
```javascript
|
||||||
request.on('response', (response) => {
|
request.on('response', (response) => {
|
||||||
console.log(`STATUS: ${response.statusCode}`);
|
console.log(`STATUS: ${response.statusCode}`);
|
||||||
response.on('error', (error) => {
|
response.on('error', (error) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user