|
1 | 1 | const config = require('config')
|
2 |
| -const fetch = require('node-fetch') |
| 2 | +const request = require('superagent') |
3 | 3 | const logger = require('../common/logger')
|
4 | 4 |
|
5 | 5 | const localLogger = {
|
@@ -35,30 +35,22 @@ async function createJob(job) {
|
35 | 35 | })
|
36 | 36 | }
|
37 | 37 |
|
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 |
| - |
57 | 38 | 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) }); |
62 | 54 | } catch (error) {
|
63 | 55 | localLogger.debug({ context: 'createJob error', message: error.message || error.toString() })
|
64 | 56 | }
|
|
0 commit comments