Skip to content

Commit

Permalink
fix(http-client): parse last field in JSON object also
Browse files Browse the repository at this point in the history
  • Loading branch information
enylin committed Dec 31, 2021
1 parent 76f87de commit ef2088b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/line-pay-api/auth-http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,16 @@ export function createAuthHttpClient(
* So we should convert the number to string.
*/
const transformResponse: AxiosResponseTransformer = data =>
JSON.parse(
data
.replace(/"transactionId":(\d+),/g, '"transactionId":"$1",')
.replace(/"refundTransactionId":(\d+),/g, '"refundTransactionId":"$1",')
)
typeof data !== 'string'
? data
: JSON.parse(
data
.replace(/"transactionId":\s*(\d+)/g, '"transactionId":"$1"')
.replace(
/"refundTransactionId":\s*(\d+)/g,
'"refundTransactionId":"$1"'
)
)

const axiosInstance = axios.create({
baseURL: BASE_URL,
Expand Down

0 comments on commit ef2088b

Please sign in to comment.