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

Remove request-promise (deprecation) #435

Merged
merged 1 commit into from May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -13,15 +13,14 @@
},
"license": "MIT",
"devDependencies": {
"node-fetch": "2.6.0",
"lerna": "^3.4.0",
"@zeit/eslint-config-node": "0.2.13",
"@zeit/git-hooks": "0.1.4",
"ava": "0.23.0",
"eslint": "4.19.1",
"husky": "0.14.3",
"nyc": "11.3.0",
"request": "2.83.0",
"request-promise": "4.2.2",
"resumer": "0.0.0",
"rewire": "3.0.2",
"sinon": "4.4.3",
Expand Down
7 changes: 4 additions & 3 deletions packages/micro/README.md
Expand Up @@ -338,7 +338,7 @@ const http = require('http')
const micro = require('micro')
const test = require('ava')
const listen = require('test-listen')
const request = require('request-promise')
const fetch = require('node-fetch')

test('my endpoint', async t => {
const service = new http.Server(micro(async (req, res) => {
Expand All @@ -348,9 +348,10 @@ test('my endpoint', async t => {
}))

const url = await listen(service)
const body = await request(url)
const response = await fetch(url)
const body = await response.json()

t.deepEqual(JSON.parse(body).test, 'woot')
t.deepEqual(body.test, 'woot')
service.close()
})
```
Expand Down
23 changes: 10 additions & 13 deletions test/development.js
@@ -1,6 +1,6 @@
// Packages
const test = require('ava');
const request = require('request-promise');
const fetch = require('node-fetch');
const listen = require('test-listen');
const http = require('http');

Expand All @@ -17,9 +17,10 @@ test('send(200, <Object>) is pretty-printed', async t => {
const fn = () => ({woot: 'yes'});

const url = await getUrl(fn);
const res = await request(url);
const res = await fetch(url);
const body = await res.text();

t.deepEqual(res, `{\n "woot": "yes"\n}`);
t.deepEqual(body, `{\n "woot": "yes"\n}`);
});

test('sendError shows stack in development without statusCode', async t => {
Expand All @@ -28,11 +29,9 @@ test('sendError shows stack in development without statusCode', async t => {
};

const url = await getUrl(fn);
try {
await request(url);
} catch (err) {
t.true(err.message.indexOf('at fn (') !== -1);
}
const res = await fetch(url);
const body = await res.text();
t.true(body.indexOf('at fn (') !== -1);
});

test('sendError shows stack in development with statusCode', async t => {
Expand All @@ -43,9 +42,7 @@ test('sendError shows stack in development with statusCode', async t => {
};

const url = await getUrl(fn);
try {
await request(url);
} catch (err) {
t.true(err.message.indexOf('at fn (') !== -1);
}
const res = await fetch(url);
const body = await res.text();
t.true(body.indexOf('at fn (') !== -1);
});