Skip to content

Commit

Permalink
Merge pull request #125 from digiAlchem/master
Browse files Browse the repository at this point in the history
Send correct request form-data headers
  • Loading branch information
Ayane Satomi authored Oct 29, 2019
2 parents cbb1cae + 4f730c5 commit 45d72da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ type File = string | Buffer | Readable;
* Creates a function to be used for finding potential sources for a given image.
*/
const sagiri = (token: string, defaultOptions: Options = { results: 5 }) => {
const request = bent('https://saucenao.com', 'json', 'POST');

log('Created Sagiri function with default options:', defaultOptions);

return async (
Expand Down Expand Up @@ -100,6 +98,14 @@ const sagiri = (token: string, defaultOptions: Options = { results: 5 }) => {
form.append('file', file);
}

const request = bent(
'https://saucenao.com',
'json',
'POST',
200,
form.getHeaders()
);

log('Sending request to SauceNAO');

const response = (await request('/search.php', form)) as Response;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sagiri",
"version": "3.0.0",
"version": "3.0.1",
"description": "A simple, lightweight and actually good JS wrapper for the SauceNAO API.",
"author": "sr229",
"license": "MIT",
Expand Down

0 comments on commit 45d72da

Please sign in to comment.