github-tools / github-tools/github
Repository.writeFile not working
- Linguagem predominante
- JavaScript
- Estrelas
- 3.8k
- Forks
- 809
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
When attempting to use Repository.writeFile, this error occurs:
```
(node:8240) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'status' of undefined
at handler (C:\Program Files\nodejs\node_modules\github-api\dist\components\Requestable.js:372:40)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8240) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:8240) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
```
Here is the code used:
```
GitHub = require("github-api");
github = new GitHub(username, password);
repo = github.getRepo(user, repo) // actual values are "kyllta", "urlshortener"
repo.writeFile(
"main",
"test_file.txt",
"test contents",
"test commit"
);
```
Any attempts to use in HTML code (Chrome) result in this error:
```
xhr.js:177 PUT https://api.github.com/repos/kyllta/urlshortener/contents/saved_urls.json 404
| (anonymous) | @ | xhr.js:177
-- | -- | -- | --
| t.exports | @ | xhr.js:13
| t.exports | @ | dispatchRequest.js:50
| Promise.then (async) | |
| n.request | @ | Axios.js:61
| (anonymous) | @ | bind.js:9
| value | @ | Requestable.js:183
| (anonymous) | @ | Repository.js:787
| Promise.then (async) | |
| value | @ | Repository.js:785
| submit | @ | (index):54
| async function (async) | |
| submit | @ | (index):32
| onclick | @ | (index):73
```
My suspicion is incorrect headers, but I don't know much.
#577 and #520 are similar, but have different errors, and so don't seem to apply.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Comece por Repository.writeFile e pelo handler de Requestable.js ao redor da linha reportada; em seguida, compare a requisição do navegador em Repository.js com os argumentos fornecidos e a resposta da API do GitHub. Verifique a correção reproduzindo a chamada de writeFile para o repositório kyllta/urlshortener sem um status undefined ou uma resposta 404.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- github, javascript
- Domínio
- api
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100