Skip to content

Commit 599e7cd

Browse files
committed
Add documentation for XHR option
Also removed trailing whitespace from "//Can be created in your profile", and since I was doing that anyway, added a space between "//" and "Can"
1 parent db2ccfc commit 599e7cd

1 file changed

Lines changed: 38 additions & 22 deletions

File tree

README.md

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const Gitlab = require('node-gitlab-api/dist/es5').default
139139
// Instantiating
140140
const api = new Gitlab({
141141
url: 'http://example.com', // Defaults to http://gitlab.com
142-
token: 'abcdefghij123456' //Can be created in your profile.
142+
token: 'abcdefghij123456' // Can be created in your profile.
143143
})
144144

145145
// Or, use a OAuth token instead!
@@ -160,7 +160,7 @@ import { Projects } from 'node-gitlab-api';
160160

161161
const service = new Projects({
162162
url: 'http://example.com', // Defaults to http://gitlab.com
163-
token: 'abcdefghij123456' //Can be created in your profile.
163+
token: 'abcdefghij123456' // Can be created in your profile.
164164
})
165165

166166
```
@@ -175,7 +175,7 @@ import { ProjectsBundle } from 'node-gitlab-api';
175175

176176
const services = new ProjectsBundle({
177177
url: 'http://example.com', // Defaults to http://gitlab.com
178-
token: 'abcdefghij123456' //Can be created in your profile.
178+
token: 'abcdefghij123456' // Can be created in your profile.
179179
})
180180

181181
services.Projects.all()
@@ -253,6 +253,22 @@ EpicNotes
253253
EpicDiscussions
254254
```
255255

256+
### Using XMLHttpRequest
257+
This package uses the [Request](https://github.com/request/request) library by default, which is built into Node. However, if your code is running in a browser, you can get better built-in resolution of proxies and self-signed certificates by using the browser's XMLHttpRequest implementation instead:
258+
259+
```javascript
260+
import Gitlab from 'node-gitlab-api';
261+
262+
const api = new Gitlab({
263+
url: 'http://example.com', // Defaults to http://gitlab.com
264+
token: 'abcdefghij123456', // Can be created in your profile.
265+
266+
useXMLHttpRequest: true // Use the browser's XMLHttpRequest instead of Node's Request library
267+
})
268+
```
269+
270+
**WARNING:** Currently this option does not support the `multipart/form-data` content type, and therefore the endpoint for [uploading a file to a project](https://docs.gitlab.com/ee/api/projects.html#upload-a-file) will not work correctly. All other endpoints should work exactly as expected.
271+
256272
### Examples
257273
Once you have your library instantiated, you can utilize many of the API's functionality:
258274

@@ -263,7 +279,7 @@ import Gitlab from 'node-gitlab-api';
263279

264280
const api = new Gitlab({
265281
url: 'http://example.com', // Defaults to http://gitlab.com
266-
token: 'abcdefghij123456' //Can be created in your profile.
282+
token: 'abcdefghij123456' // Can be created in your profile.
267283
});
268284

269285
// Listing users
@@ -280,14 +296,14 @@ General rule about all the function parameters:
280296
- If its a required parameter, it is a named argument in the functions
281297
- If its an optional parameter, it is defined in a options object following the named arguments
282298

283-
ie.
299+
ie.
284300

285301
```javascript
286302
import Gitlab from 'node-gitlab-api';
287303

288304
const api = new Gitlab({
289305
url: 'http://example.com', // Defaults to http://gitlab.com
290-
token: 'abcdefghij123456' //Can be created in your profile.
306+
token: 'abcdefghij123456' // Can be created in your profile.
291307
});
292308

293309
api.Projects.create(projectId, {
@@ -305,7 +321,7 @@ import Gitlab from 'node-gitlab-api';
305321

306322
const api = new Gitlab({
307323
url: 'http://example.com', // Defaults to http://gitlab.com
308-
token: 'abcdefghij123456' //Can be created in your profile.
324+
token: 'abcdefghij123456' // Can be created in your profile.
309325
});
310326

311327
let projects = await api.Projects.all({maxPages:2});
@@ -319,7 +335,7 @@ import Gitlab from 'node-gitlab-api';
319335

320336
const api = new Gitlab({
321337
url: 'http://example.com', // Defaults to http://gitlab.com
322-
token: 'abcdefghij123456' //Can be created in your profile.
338+
token: 'abcdefghij123456' // Can be created in your profile.
323339
});
324340

325341
let projects = await api.Projects.all({maxPages:2, perPage:40});
@@ -328,7 +344,7 @@ let projects = await api.Projects.all({maxPages:2, perPage:40});
328344

329345
## Docs
330346

331-
Although there are the official docs for the API, there are some extra goodies offered by this package! After the 3.0.0 release, the next large project will be putting together proper documention for these goodies [#39]! Stay tuned!!
347+
Although there are the official docs for the API, there are some extra goodies offered by this package! After the 3.0.0 release, the next large project will be putting together proper documention for these goodies [#39]! Stay tuned!!
332348

333349
## Tests
334350

@@ -345,7 +361,7 @@ This started off as a fork from [node-gitlab](https://github.com/node-gitlab/nod
345361
- [Christoph Lehmann](https://github.com/christophlehmann)
346362
- [Frank V](https://github.com/FrankV01)
347363
- [Salim Benabbou](https://github.com/Salimlou)
348-
- [Tamás Török-Vistai](https://github.com/tvtamas)
364+
- [Tamás Török-Vistai](https://github.com/tvtamas)
349365
- [Martin Benninger](https://github.com/MartinBenninger)
350366
- [Adam Dehnel](https://github.com/arsdehnel)
351367
- [fewieden](https://github.com/fewieden)
@@ -412,13 +428,13 @@ Runners = ProjectRunners + Runners. ProjectId is optional for all()
412428
------------------
413429
- Fixing babel runtime
414430

415-
[2.2.6](https://github.com/jdalrymple/node-gitlab-api/tags/2.2.6) (2018-3-15)
416-
------------------
417-
- Fixed more issues within the url concatenation
431+
[2.2.6](https://github.com/jdalrymple/node-gitlab-api/tags/2.2.6) (2018-3-15)
432+
------------------
433+
- Fixed more issues within the url concatenation
418434

419-
[2.2.5](https://github.com/jdalrymple/node-gitlab-api/tags/2.2.5) (2018-3-15)
420-
------------------
421-
- Fixed #48 - Problem with trailing `\` in url
435+
[2.2.5](https://github.com/jdalrymple/node-gitlab-api/tags/2.2.5) (2018-3-15)
436+
------------------
437+
- Fixed #48 - Problem with trailing `\` in url
422438

423439
[2.2.4](https://github.com/jdalrymple/node-gitlab-api/5d7c031ca2b833b28633647195560379d88ba5b3) (2018-2-12)
424440
------------------
@@ -440,7 +456,7 @@ Runners = ProjectRunners + Runners. ProjectId is optional for all()
440456

441457
[2.2.3](https://github.com/jdalrymple/node-gitlab-api/ce7f17693168b5dec3b36eb1d5ab796c9374613f) (2018-2-3)
442458
------------------
443-
- Fixed #37 - Bug within the customAttributes logic
459+
- Fixed #37 - Bug within the customAttributes logic
444460

445461
[2.2.2](https://github.com/jdalrymple/node-gitlab-api/ca1906879d869bf5b9aca0b2f64e46c89f3b5f4f) (2018-1-24)
446462
------------------
@@ -469,7 +485,7 @@ how to run locally via npm linking for Development testing thanks to [Adam Dehne
469485
- Updating project docs for consistency
470486
- Adding project unsharing to API. It was in the docs, but missing from the API
471487
- Updating deprecated protected branches endpoint. Previously this was `projects.branches.protect` now its `projects.protectedBranches.protect`
472-
- Added Owned Runners and Runner Jobs API
488+
- Added Owned Runners and Runner Jobs API
473489

474490
### Breaking Changes between 1.3.3 and 2.1.0
475491
- The `list` functions are no longer supported and have all been renamed to `all`
@@ -487,7 +503,7 @@ how to run locally via npm linking for Development testing thanks to [Adam Dehne
487503
- Updating pagination changes into v2.0.1
488504
- Removed unused labels endpoint since it already exists under projects.labels
489505
- Added a mergeRequests class for the merge_requests endpoints
490-
- Extended the ProjectMergeRequests class for additional functionality that was missing for project merge requests such as
506+
- Extended the ProjectMergeRequests class for additional functionality that was missing for project merge requests such as
491507
accepting merge requests, cancelling merges when the pipeline succeeds, listing issues that will close on merge, subscribing/unsubscribing to merges, creating todos, time spent and time estimates as well as time stats.
492508
- Fixed the notes endpoints for ProjectMergeRequests. This can now be access via projects.mergeRequests.notes.[command here]
493509
- Added comments endpoints to the ProjectRepositoryCommits class
@@ -497,7 +513,7 @@ accepting merge requests, cancelling merges when the pipeline succeeds, listing
497513
[1.3.3](https://github.com/jdalrymple/node-gitlab-api/b8a3db4a4aaf9482fb3905883d92d940babfb461) (2017-11-29)
498514
------------------
499515
- Adding pagination to project pipelines thanks to [Tamás Török-Vistai](https://github.com/tvtamas)
500-
516+
501517
[2.0.0-rc.2](https://github.com/jdalrymple/node-gitlab-api/62a4d360f0ca2cd584caf852d96ced3761992072) (2017-11-28)
502518
------------------
503519
- Updating all recent core changes into v2.0.0
@@ -556,7 +572,7 @@ accepting merge requests, cancelling merges when the pipeline succeeds, listing
556572

557573
[1.1.1](https://github.com/jdalrymple/node-gitlab-api/67df1c8772614b3856f2995eaa7d260d0f697e49) (2017-09-24)
558574
------------------
559-
- Patch, fixed a broken pagination property
575+
- Patch, fixed a broken pagination property
560576
- Adding in missing options parameter in the groups API thanks to a pull request from [Cory Zibell](https://github.com/coryzibell)
561577

562578
[1.1.0](https://github.com/jdalrymple/node-gitlab-api/385ef9f351981f26180e1381525ade458bcde1cd) (2017-09-24)
@@ -663,4 +679,4 @@ to this
663679
"node-gitlab-api": "<path-to-your-clone>"
664680
...
665681
}
666-
```
682+
```

0 commit comments

Comments
 (0)