Skip to content

Commit 91116c8

Browse files
committed
update http to request
Signed-off-by: Hunter Achieng <[email protected]>
1 parent 295712f commit 91116c8

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

packages/rapidpro/src/Adaptor.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import {
33
composeNextState,
44
http, // Important: this is the OLD axios-based http.
55
} from '@openfn/language-common';
6-
import { expandReferences } from '@openfn/language-common/util';
6+
import {
7+
expandReferences,
8+
logResponse,
9+
request,
10+
} from '@openfn/language-common/util';
711

812
const { axios } = http;
913
export { axios };
@@ -56,23 +60,19 @@ export function addContact(params, callback) {
5660

5761
const url = `${host}/api/${apiVersion || 'v2'}/contacts.json`;
5862

59-
const config = {
60-
url,
61-
data: resolvedParams,
63+
return request('POST', url, {
64+
body: resolvedParams,
6265
headers: { Authorization: `Token ${token}` },
63-
};
64-
65-
return http
66-
.post(config)(state)
67-
.then(response => {
68-
console.log('Contact added with uuid:', response.data.uuid);
69-
const nextState = {
70-
...composeNextState(state, response.data),
71-
response,
72-
};
73-
if (callback) return callback(nextState);
74-
return nextState;
75-
});
66+
}).then(response => {
67+
logResponse(response);
68+
console.log('Contact added with uuid:', response.body.uuid);
69+
const nextState = {
70+
...composeNextState(state, response.data),
71+
response,
72+
};
73+
if (callback) return callback(nextState);
74+
return nextState;
75+
});
7676
};
7777
}
7878

@@ -103,7 +103,15 @@ export function upsertContact(params, callback) {
103103
data: resolvedParams,
104104
headers: { Authorization: `Token ${token}` },
105105
};
106+
const response = request('POST', url, {
107+
body: resolvedParams,
108+
headers: { Authorization: `Token ${token}` },
109+
}).then(response => {
110+
logResponse(response);
111+
console.log('Contact added with uuid:', response.body.uuid);
112+
return response
106113

114+
})
107115
return http
108116
.post(config)(state)
109117
.then(resp => {

0 commit comments

Comments
 (0)