Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated request #309

Open
guimard opened this issue Nov 4, 2020 · 4 comments
Open

Replace deprecated request #309

guimard opened this issue Nov 4, 2020 · 4 comments

Comments

@guimard
Copy link
Contributor

guimard commented Nov 4, 2020

Hi,
request is deprecated. One way to replace it could be to use node-fetch:

--- a/lib/sendToCoveralls.js
+++ b/lib/sendToCoveralls.js
@@ -1,6 +1,6 @@
 'use strict';

-const request = require('request');
+const fetch = require('node-fetch');
 const index = require('..');

 const sendToCoveralls = (obj, cb) => {
@@ -16,13 +16,14 @@
     process.stdout.write(str);
     cb(null, { statusCode: 200 }, '');
   } else {
-    request.post({
-      url,
-      form: {
-        json: str
-      }
-    }, (err, response, body) => {
-      cb(err, response, body);
+    fetch(url, {
+      method: "post",
+      body: str,
+      headers: { 'Content-Type': 'application/json' },
+    }).then(res => {
+      cb(null, res, res.body);
+    }).catch(err => {
+      cb(err);
     });
   }
 };

Of course, test must be updated also

@jtwebman
Copy link

I did it here with got library: #311

@jtwebman
Copy link

jtwebman commented Feb 7, 2021

I also forked this repo as it had been a few months with no response and used GOT as well as fixed all the other warnings here: https://github.com/jtwebman/coveralls-next

@AndreMaz
Copy link

Hi @nickmerwin any chance of making this happen? #311 seems to solve the issue

@jtwebman
Copy link

jtwebman commented Mar 6, 2022

Since this library doesn't seem to be supported anymore I fix a bunch of things on a fork if you want to check it out and are still pulling the library into your packages: https://github.com/jtwebman/coveralls-next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants