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: README.md
+43-14Lines changed: 43 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,12 @@ Our JavaScript client implements a common interface which is implemented at [`@i
38
38
39
39
### Configuration & Usage
40
40
41
+
-[Install](#install)
42
+
-[Instantiate](#instantiate) and [Use](#use) client
43
+
-[Catch Errors](#catch-errors)
44
+
-[Configure Agent](#configure-agent)
45
+
-[Proxy HTTP Requests](#proxy-requests)
46
+
41
47
#### Install
42
48
43
49
```bash
@@ -78,26 +84,49 @@ try {
78
84
}
79
85
```
80
86
87
+
#### Configure HTTP Agent
88
+
89
+
`core-node` uses [got](https://github.com/sindresorhus/got) as its underlying HTTP client. The Ideal Postcodes API client can also be optionally configured with a [got](https://github.com/sindresorhus/got) options object which is fed to [got](https://github.com/sindresorhus/got) on every request.
90
+
91
+
Be aware this options object will overwrite any existing [got](https://github.com/sindresorhus/got) HTTP request parameters.
92
+
93
+
```javascript
94
+
constclient=newClient({ api_key:"iddqd" }, {
95
+
cache:newMap, // Instantiate a cache: https://github.com/sindresorhus/got#cache-1
96
+
hooks: { // Hook into HTTP responses: https://github.com/sindresorhus/got#hooksafterresponse
97
+
afterResponse:response=> {
98
+
log(response);
99
+
return response;
100
+
}
101
+
},
102
+
});
103
+
```
104
+
105
+
#### Proxy HTTP Requests
106
+
107
+
You can [proxy requests](https://github.com/sindresorhus/got#proxies) by configuring the underlying [got](https://github.com/sindresorhus/got) HTTP client.
108
+
109
+
```javascript
110
+
consttunnel=require("tunnel");
111
+
112
+
constclient=newClient(config, {
113
+
agent:tunnel.httpOverHttp({
114
+
proxy: {
115
+
host:"localhost"
116
+
}
117
+
})
118
+
});
119
+
```
120
+
81
121
---
82
122
83
123
### Quickstart
84
124
85
125
The client exposes a number of simple methods to get at the most common tasks when interacting with the API. Below is a (incomplete) list of commonly used methods.
-[Search for an Address by UDPRN](#search-for-an-address-by-udprn)
99
-
-[Test](#test)
100
-
-[Licence](#licence)
127
+
-[Lookup a Postcode](#lookup-a-postcode)
128
+
-[Search for an Address](#search-for-an-address)
129
+
-[Search for an Address by UDPRN](#search-for-an-address-by-udprn)
101
130
102
131
For a complete list of client methods, including low level resource methods, please see the [core-interface documentation](https://core-interface.ideal-postcodes.dev/#documentation)
0 commit comments