Skip to content

Commit 4fecf6f

Browse files
fix: 🐛 create function response data update
1 parent 12c475f commit 4fecf6f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

lib/entity.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ export const create = ({ http, params }) => {
8686
if (response.data) {
8787
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid))
8888
} else {
89-
throw error(response)
89+
if (response.status >= 200 && response.status < 300) {
90+
return {
91+
status: response.status,
92+
statusText: response.statusText
93+
}
94+
} else {
95+
throw error(response)
96+
}
9097
}
9198
} catch (err) {
9299
throw error(err)
@@ -301,4 +308,4 @@ export const move = (http, type, force = false, params = {}) => {
301308
throw error(err)
302309
}
303310
}
304-
}
311+
}

test/api/team-users-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ describe('Teams Users API Test', () => {
1919
emails: ['email@email.com']
2020
}
2121
makeUsers(organizationUid, teamUid).add(usersMail).then((response) => {
22-
expect(response).to.be.equal(null)
22+
expect(response.status).to.be.equal(201)
23+
done()
2324
})
2425
.catch(done)
2526
})

test/typescript/teamUsers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function testTeamUsers (organization: Organization) {
99
emails: ['email@email.com']
1010
}
1111
organization.teams(teamUid).users().add(usersMail).then((response) => {
12-
expect(response).not.to.be.equal(null)
12+
expect(response.status).to.be.eql(201)
1313
done()
1414
})
1515
.catch(done)
@@ -24,7 +24,7 @@ export function testTeamUsers (organization: Organization) {
2424
})
2525
test('should fetch all users', done => {
2626
organization.teams(teamUid).users()
27-
.fetchAll()
27+
.fetchAll()
2828
.then((response) => {
2929
expect(response.items[0]).not.to.be.equal(undefined)
3030
done()

0 commit comments

Comments
 (0)