Browse Source

fix: axios webboundary (#5)

* chore: update openapi

* fix: Axios bug boundary not set default (Axios browser version)
pull/6/head
Aldino Kemal 4 years ago
committed by GitHub
parent
commit
1eb92df2d1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      openapi.yaml
  2. 24
      views/index.html

12
openapi.yaml

@ -406,7 +406,7 @@ paths:
schema: schema:
type: object type: object
properties: properties:
phone_number:
phone:
type: integer type: integer
example: '6289685024091' example: '6289685024091'
message: message:
@ -460,7 +460,7 @@ paths:
type: object type: object
example: example:
code: 400 code: 400
message: 'phone_number: cannot be blank.'
message: 'phone: cannot be blank.'
results: null results: null
'500': '500':
description: Internal Server Error description: Internal Server Error
@ -496,7 +496,7 @@ paths:
schema: schema:
type: object type: object
properties: properties:
phone_number:
phone:
type: integer type: integer
example: '6289685024091' example: '6289685024091'
caption: caption:
@ -556,7 +556,7 @@ paths:
type: object type: object
example: example:
code: 400 code: 400
message: 'phone_number: cannot be blank.'
message: 'phone: cannot be blank.'
results: null results: null
'500': '500':
description: Internal Server Error description: Internal Server Error
@ -592,7 +592,7 @@ paths:
schema: schema:
type: object type: object
properties: properties:
phone_number:
phone:
type: integer type: integer
example: '6289685024091' example: '6289685024091'
caption: caption:
@ -652,7 +652,7 @@ paths:
type: object type: object
example: example:
code: 400 code: 400
message: 'phone_number: cannot be blank.'
message: 'phone: cannot be blank.'
results: null results: null
'500': '500':
description: Internal Server Error description: Internal Server Error

24
views/index.html

@ -529,7 +529,13 @@
payload.append("phone", this.message_phone) payload.append("phone", this.message_phone)
payload.append("message", this.message_text) payload.append("message", this.message_text)
payload.append("type", this.message_type) payload.append("type", this.message_type)
let response = await axios.post(`${this.app_host}/send/message`, payload)
let response = await axios.post(`${this.app_host}/send/message`, payload, {
// Axios Bug, always content-type that make boundary not set default by browser https://github.com/axios/axios/issues/1603
transformRequest: (data, headers) => {
delete headers.post['Content-Type'];
return data;
}
})
this.sendMessageReset(); this.sendMessageReset();
resolve(response.data.message) resolve(response.data.message)
} catch (error) { } catch (error) {
@ -578,7 +584,13 @@
payload.append("caption", this.image_caption) payload.append("caption", this.image_caption)
payload.append("image", $("#image_file")[0].files[0]) payload.append("image", $("#image_file")[0].files[0])
payload.append("type", this.image_type) payload.append("type", this.image_type)
let response = await axios.post(`${this.app_host}/send/image`, payload)
let response = await axios.post(`${this.app_host}/send/image`, payload, {
// Axios Bug, always content-type that make boundary not set default by browser https://github.com/axios/axios/issues/1603
transformRequest: (data, headers) => {
delete headers.post['Content-Type'];
return data;
}
})
this.sendImageReset(); this.sendImageReset();
resolve(response.data.message) resolve(response.data.message)
} catch (error) { } catch (error) {
@ -626,7 +638,13 @@
payload.append("phone", this.file_phone) payload.append("phone", this.file_phone)
payload.append("file", $("#file_file")[0].files[0]) payload.append("file", $("#file_file")[0].files[0])
payload.append("type", this.file_type) payload.append("type", this.file_type)
let response = await axios.post(`${this.app_host}/send/file`, payload)
let response = await axios.post(`${this.app_host}/send/file`, payload, {
// Axios Bug, always content-type that make boundary not set default by browser https://github.com/axios/axios/issues/1603
transformRequest: (data, headers) => {
delete headers.post['Content-Type'];
return data;
}
})
this.sendFileReset(); this.sendFileReset();
resolve(response.data.message) resolve(response.data.message)
} catch (error) { } catch (error) {

Loading…
Cancel
Save