Skip to content

Commit 0f7c12d

Browse files
authored
Merge pull request #93 from hongwei1/develop
bugfix/added the Content-Type for create and post endpoint
2 parents 3b13d0a + c3793e3 commit 0f7c12d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/obp/index.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ export async function get(path: string): Promise<any> {
5252

5353
export async function create(path: string, body: any): Promise<any> {
5454
try {
55-
return (await superagent.post(`/api/create?path=${path}`).send(JSON.parse(body))).body
55+
return (await superagent.post(`/api/create?path=${path}`)
56+
.set('Content-Type', 'application/json')
57+
.send(JSON.parse(body)))
58+
.body
5659
} catch (error) {
5760
console.log(error)
5861
return { error }
@@ -61,7 +64,9 @@ export async function create(path: string, body: any): Promise<any> {
6164

6265
export async function update(path: string, body: any): Promise<any> {
6366
try {
64-
return (await superagent.put(`/api/update?path=${path}`).send(JSON.parse(body))).body
67+
return (await superagent.put(`/api/update?path=${path}`)
68+
.set('Content-Type', 'application/json')
69+
.send(JSON.parse(body))).body
6570
} catch (error) {
6671
console.log(error)
6772
return { error }

0 commit comments

Comments
 (0)