If you plan to use Octokit, I recommend you to try @octokit/rest.js
. This API Client SDK will help you bypass most of the headaches when interacting with GitHub's API.
Checking their docs you can find the equivalent to doing octokit.request('POST /repos/{owner}/{repo}/releases/{release_id}/assets', ...)
:
octokit.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id,
name,
data,
});
Also, in github.com/@octokit/rest.js, I found a example in /tests which probably will be useful to you as guidance: @octokit/rest.js -> release-assets.test.ts:
octokit.request({
method: "POST",
url: result.data.upload_url,
headers: {
"content-type": "text/plain",
},
data: "Hello, world!\n",
name: "test-upload.txt",
label: "test",
});
})