Skip to content

Commit 55c9b54

Browse files
committed
use superagent
1 parent bb6662b commit 55c9b54

File tree

3 files changed

+16
-67
lines changed

3 files changed

+16
-67
lines changed

package-lock.json

Lines changed: 0 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"joi": "^17.4.2",
2727
"lodash": "^4.17.20",
2828
"no-kafka": "^3.4.3",
29-
"node-fetch": "^3.3.2",
3029
"superagent": "^8.1.2",
3130
"tc-core-library-js": "^2.4.1",
3231
"topcoder-healthcheck-dropin": "^1.0.3",

src/services/RCRMService.js

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const config = require('config')
2-
const fetch = require('node-fetch')
2+
const request = require('superagent')
33
const logger = require('../common/logger')
44

55
const localLogger = {
@@ -35,30 +35,22 @@ async function createJob(job) {
3535
})
3636
}
3737

38-
const options = {
39-
method: 'POST',
40-
headers: {
41-
'Content-Type': 'application/json',
42-
Accept: 'application/json',
43-
Authorization: `Bearer ${config.RCRM.API_KEY}`
44-
},
45-
body: JSON.stringify({
46-
name: job.title,
47-
number_of_openings: job.numPositions,
48-
company_slug: config.RCRM.COMPANY_SLUG,
49-
contact_slug: config.RCRM.CONTACT_SLUG,
50-
job_description_text: job.description,
51-
currency_id: 2,
52-
custom_fields,
53-
enable_job_application_form: 0
54-
})
55-
};
56-
5738
try {
58-
const rsp = await fetch(`${config.RCRM.API_BASE}/jobs`, options);
59-
const data = await rsp.json();
60-
61-
localLogger.debug({ context: 'createJob done', message: JSON.stringify(data) });
39+
const rsp = await request
40+
.post(`${config.RCRM.API_BASE}/jobs`)
41+
.set('Authorization', `Bearer ${config.RCRM.API_KEY}`)
42+
.send({
43+
name: job.title,
44+
number_of_openings: job.numPositions,
45+
company_slug: config.RCRM.COMPANY_SLUG,
46+
contact_slug: config.RCRM.CONTACT_SLUG,
47+
job_description_text: job.description,
48+
currency_id: 2,
49+
custom_fields,
50+
enable_job_application_form: 0
51+
})
52+
53+
localLogger.debug({ context: 'createJob', message: JSON.stringify(rsp) });
6254
} catch (error) {
6355
localLogger.debug({ context: 'createJob error', message: error.message || error.toString() })
6456
}

0 commit comments

Comments
 (0)