You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: migration_guide_v10_to_v11.md
+34-2Lines changed: 34 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,17 @@
1
1
# Migrating from Nano 10 to Nano 11
2
2
3
-
Nano 10 uses the Axios library as an HTTP/HTTPS client. Keeping up with changes to Axios and its dependencies made maintaining this library a chore, so as of Nano 11 we use Node.js's built-in _fetch_ API as our HTTP client. This makes Nano a _zero dependency_ library which makes for faster installs, easier maintenance and slightly better performance.
3
+
The highlights:
4
4
5
-
There are some things to bear in mind if you are switching from Nano 10 to Nano 11, so please consider the following advice carefully before you do.
5
+
- Nano 11's HTTP client is replaced with the native Node.js _fetch_ function meaning that Nano 11 only works on Node.js 18 and above.
6
+
- Nano no longer supports `requestDefaults` to configure the client options.
7
+
- Nano no longer supports callbacks.
6
8
7
9
## Node.js versions
8
10
9
11
> ** Nano 11 is a breaking change for users of Node.s 16 or earlier **
10
12
13
+
Nano 10 uses the Axios library as an HTTP/HTTPS client. Keeping up with changes to Axios and its dependencies made maintaining this library a chore, so as of Nano 11 we use Node.js's built-in _fetch_ API as our HTTP client. This makes Nano a _zero dependency_ library which makes for faster installs, easier maintenance and slightly better performance.
14
+
11
15
Nano 11 is only compatible with Node.js versions 18 and older, because it is only these Node versions that have the [fetch](https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#fetch) HTTP client baked in. See [Node.js's Long-term Support page](https://nodejs.org/en/about/previous-releases) to see which are the currently supported and maintained versions. In short:
12
16
13
17
- If you are using Node.js 18 or newer, use Nano 11.
@@ -17,6 +21,8 @@ Nano 10 may continue to receive some security fixes for a time, but Nano 11 repr
17
21
18
22
## Agent options
19
23
24
+
> ** Nano 11 no longer supports `requestDefaults` to configure the HTTP client **
25
+
20
26
None of Nano's API has changed _except_ when a user is supplying non-default connection handling parameters. Gone is `requestDefaults` which dates back to the "request" days and instead an optional `agentOptions` can be provided which is documented in the README and in TypeScript.
> Note: to supply a custom agent, you will need the [undici](https://www.npmjs.com/package/undici) module as a dependency in your own project. Undici is the library that powers Node.js's _fetch_ API but its "Agent" is not programmatically accessible unless undici is imported separately.
45
51
52
+
## Callbacks
53
+
54
+
> ** Nano 11 no longer supports callbacks **
55
+
56
+
In Nano 10 and earlier, the last parameter to most Nano functions was a callback so you could do:
57
+
58
+
```js
59
+
db.list(function(err, data) {
60
+
console.log('response', err, data)
61
+
})
62
+
```
63
+
64
+
This was the way asynchronous activity was handled in the early days of Node.js but as of Nano 11 all callbacks are removed and we expect the use of Promises:
65
+
66
+
```js
67
+
db.list().then((data) => { console.log('response', data )})
68
+
```
69
+
70
+
or more commonly, the `await` pattern:
71
+
72
+
```js
73
+
constdata=awaitdb.list()
74
+
console.log('response', data)
75
+
```
76
+
77
+
If your code makes use of the callback style then **it will not work with Nano 11**: you will need to rewrite your code to use Promises or await, or remain on Nano 10.
0 commit comments