Skip to content

Commit

Permalink
test: include more info about fairos error
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorShadurin committed Oct 15, 2023
1 parent d0323b2 commit 64d26d6
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions test/utils/fairos-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,24 @@ export class FairOSApi {

return config
})
axios.interceptors.response.use(response => {
if (this.withCredentials && response.headers['set-cookie']) {
this.cookies = response.headers['set-cookie']?.[0] as string
}
axios.interceptors.response.use(
response => {
if (this.withCredentials && response.headers['set-cookie']) {
this.cookies = response.headers['set-cookie']?.[0] as string
}

return response
})
return response
},
error => {
if (error.response) {
// Append server response to error message
throw new Error(`AxiosError: ${error.message}. Server response: ${error.response?.data}`)
} else {
// Something happened while setting up the request
throw error
}
},
)
}

private getV2Url(method: string) {
Expand Down Expand Up @@ -73,7 +84,7 @@ export class FairOSApi {
async login(username: string, password: string): Promise<AxiosResponse> {
const url = this.getV2Url('user/login')

return await axios.post(url, {
return axios.post(url, {
userName: username,
password,
})
Expand All @@ -85,7 +96,7 @@ export class FairOSApi {
async register(username: string, password: string, mnemonic: string): Promise<AxiosResponse> {
const url = this.getV2Url('user/signup')

return await axios.post(url, {
return axios.post(url, {
userName: username,
password,
mnemonic,
Expand Down

0 comments on commit 64d26d6

Please sign in to comment.