Skip to content

Commit fec10e8

Browse files
committed
Update javascript and ruby notes
1 parent 58552de commit fec10e8

File tree

7 files changed

+60
-4
lines changed

7 files changed

+60
-4
lines changed

notes/language/javascript/fetch.md

+30-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,37 @@ title: Fetch
33
ref: https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch
44
---
55

6-
## Basic
6+
## Request
77

8-
Issue a GET request:
8+
A [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request)
9+
is built of an `input` (URL) and `options`.
10+
11+
Make a GET request:
12+
13+
```js
14+
fetch('https://example.com/').then(callback);
15+
```
16+
17+
Make a `application/json` POST request:
18+
19+
```js
20+
const url = 'https://example.com/';
21+
const options = {
22+
headers: { 'Content-Type': 'application/json' },
23+
method: 'POST',
24+
body: JSON.stringify({ username: 'example' }),
25+
};
26+
fetch(url, options).then(callback);
27+
```
28+
29+
## Response
30+
31+
A [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response)
32+
object is returned.
933

1034
```js
11-
fetch('https://example.com/').then(res => console.log(res.status));
35+
fetch('https://example.com/').then((res) => {
36+
console.log(res.status);
37+
res.text().then((text) => console.log(text));
38+
});
1239
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: Built-in
3+
ref: https://nodejs.org/api/process.html
4+
---
5+
6+
## Process
7+
8+
| Variable | Description |
9+
| ------------- | ----------------------------------------- |
10+
| `process.env` | A object containing the user environment. |
File renamed without changes.
File renamed without changes.

notes/language/ruby/builtin.md notes/language/ruby/built_in.md

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ Open the interactive console:
1616
irb
1717
```
1818

19+
## Variables
20+
21+
| Variable | Description |
22+
| -------- | --------------------------------------- |
23+
| `ENV` | A hash containing the user environment. |
24+
1925
## Functions
2026

2127
Simple printing:

notes/language/ruby/library/http.md

+13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Library to make HTTP requests.
1111
require 'net/http'
1212
```
1313

14+
## Request
15+
1416
Make a GET request:
1517

1618
```ruby
@@ -25,3 +27,14 @@ url = URI('https://example.com/')
2527
data = JSON.generate(myhash)
2628
Net::HTTP.post(url, data, { 'content-type': 'application/json' })
2729
```
30+
31+
## Response
32+
33+
A [Net::HTTPResponse](https://docs.ruby-lang.org/en/3.4/Net/HTTPResponse.html)
34+
object is returned.
35+
36+
```ruby
37+
res = Net::HTTP.post(...)
38+
puts res.code
39+
puts res.body
40+
```

notes/language/shell_script/zsh/builtins.md notes/language/shell_script/zsh/built_in.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Built-ins
2+
title: Built-in
33
man: zshbuiltins
44
---
55

0 commit comments

Comments
 (0)