https://github.com/lochungtin/github-fetch
Fetch any file from any public github repository
https://github.com/lochungtin/github-fetch
axios fetch github npm-package readme
Last synced: 3 months ago
JSON representation
Fetch any file from any public github repository
- Host: GitHub
- URL: https://github.com/lochungtin/github-fetch
- Owner: lochungtin
- License: mit
- Created: 2021-04-17T17:07:28.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-11T14:11:00.000Z (about 5 years ago)
- Last Synced: 2025-10-22T00:30:28.457Z (8 months ago)
- Topics: axios, fetch, github, npm-package, readme
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@enigmaoffline/github-fetch
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Github Fetch
Fetch any raw file from a public github repository
## Install
Installing with npm
`npm i --save @enigmaoffline/github-fetch`
## Usage
Importing
```js
const GHFetch = require("github-fetch");
```
With `.then`
```js
GHFetch.fetchFile({
username: "lochungtin",
fileName: "src/index.ts",
repo: "github-fetch",
}).then((res) => console.log(res));
```
With `async await`
```js
(async () => {
const readmeFile = await GHFetch.fetchReadme({
username: "lochungtin",
repo: "github-fetch",
});
console.log(readmeFile);
})();
```
### Fetch Parameters
Fetch Parameters for `fetchFile()`
| fetchFile() | required? | default | type |
| :---------: | :-------: | :-----: | :----: |
| username | yes | none | String |
| filename | yes | none | String |
| repo | yes | none | String |
| branch | no | master | String |
Fetch Parameters for `fetchReadme()`
| fetchReadme() | required? | default | type |
| :-----------: | :-------: | :-----: | :----: |
| username | yes | none | String |
| repo | yes | none | String |
| branch | no | master | String |
**NOTE** that all names are case sensitive.