Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit 67f6b86

Browse files
committed
"form" -> "json"
1 parent 59b5c54 commit 67f6b86

File tree

5 files changed

+10
-30
lines changed

5 files changed

+10
-30
lines changed

src/call.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,7 @@ async function call(...args) {
4343

4444
let response;
4545
try {
46-
response = await got.post(this.fullAddress_('/cbm/call/'), {
47-
encoding: 'utf-8',
48-
body: params,
49-
form: true,
50-
json: true,
51-
headers: { returnCode },
52-
});
46+
response = await got.post(this.fullAddress_('/cbm/call/'), { body: params, json: true, headers: { returnCode } });
5347
} catch (error) {
5448
({ response } = error);
5549
}

src/create.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ async function createConcept(params, host) {
1010
}
1111
try {
1212
const res = await got.post(path, {
13-
encoding: 'utf-8',
1413
body: {
1514
name: getURI(params.name),
1615
desc: params.desc,
1716
units: [].concat(params.units).map(el => getURI(el)),
1817
},
19-
form: true,
18+
json: true,
2019
});
2120
return res.statusCode === 200;
2221
} catch (error) {
@@ -31,7 +30,6 @@ async function createFunction(params, host) {
3130
}
3231
try {
3332
const res = await got.post(path, {
34-
encoding: 'utf-8',
3533
body: {
3634
name: params.name,
3735
desc: params.desc,
@@ -40,7 +38,7 @@ async function createFunction(params, host) {
4038
returnsNames: [].concat(params.returnsNames).map(el => getURI(el)),
4139
returnsUnits: [].concat(params.returnsUnits).map(el => getURI(el)),
4240
},
43-
form: true,
41+
json: true,
4442
});
4543
return res.statusCode === 200;
4644
} catch (error) {
@@ -74,10 +72,7 @@ async function createAsyncFunction(params, callPath, host) {
7472

7573
try {
7674
const res = await got.post(path, { body: form });
77-
await got.post(callPath, {
78-
body: { command: 'fixit' },
79-
form: true,
80-
});
75+
await got.post(callPath, { body: { command: 'fixit' }, json: true });
8176
return res.statusCode === 200;
8277
} catch (error) {
8378
return false;
@@ -91,15 +86,14 @@ async function createRelation(params, host) {
9186
}
9287
try {
9388
const res = await got.post(path, {
94-
encoding: 'utf-8',
9589
body: {
9690
name: params.name,
9791
desc: params.desc,
9892
start: getURI(params.start),
9993
end: getURI(params.end),
10094
mathRelation: params.mathRelation,
10195
},
102-
form: true,
96+
json: true,
10397
});
10498
return res.statusCode === 200;
10599
} catch (error) {
@@ -143,10 +137,7 @@ async function create(...args) {
143137
created = createRelation(params, this.host);
144138
}
145139
try {
146-
await got.post(path, {
147-
body: { command: 'fixit' },
148-
form: true,
149-
});
140+
await got.post(path, { body: { command: 'fixit' }, json: true });
150141
} catch (error) { /**/ }
151142
return created;
152143
}

src/get-code.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function getCode(...args) {
1919
path = codeFile[0] === '_' ? this.fullAddress_(`/js/internal/${codeFile}`) : this.fullAddress_(`/js/${codeFile}`);
2020
}
2121

22-
const res = await got(path, { encoding: 'utf-8' });
22+
const res = await got(path);
2323
return res.body;
2424
}
2525

src/search.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ async function search(...args) {
2323
}
2424
let response;
2525
try {
26-
response = await got.post(this.fullAddress_('/gbm/search/'), {
27-
encoding: 'utf-8',
28-
body: params,
29-
form: true,
30-
json: true,
31-
});
26+
response = await got.post(this.fullAddress_('/gbm/search/'), { body: params, json: true });
3227
} catch (error) {
3328
({ response } = error);
3429
}

tests/create.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const HOST = process.env.HOST || 'https://call-by-meaning.herokuapp.com';
99
test.after.always(async () => {
1010
const cbm = new CallByMeaning(HOST);
1111
const path = cbm.host.concat('/new/fix');
12-
await got.post(path, { body: { command: 'fixtests' }, form: true });
13-
await got.post(path, { body: { command: 'fixit' }, form: true });
12+
await got.post(path, { body: { command: 'fixtests' }, json: true });
13+
await got.post(path, { body: { command: 'fixit' }, json: true });
1414
});
1515

1616
test('throws an error if not supplied at least one argument', async (t) => {

0 commit comments

Comments
 (0)