Skip to content

fix: AppwriteExecption already read #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "react-native-appwrite",
"homepage": "https://appwrite.io/support",
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
"version": "0.7.1",
"version": "0.7.2",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
14 changes: 10 additions & 4 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Client {
'x-sdk-name': 'React Native',
'x-sdk-platform': 'client',
'x-sdk-language': 'reactnative',
'x-sdk-version': '0.7.1',
'x-sdk-version': '0.7.2',
'X-Appwrite-Response-Format': '1.6.0',
};

Expand Down Expand Up @@ -452,8 +452,8 @@ class Client {

try {
let data = null;

const response = await fetch(url.toString(), options);
const text = await response.text()

const warnings = response.headers.get('x-appwrite-warning');
if (warnings) {
Expand All @@ -464,12 +464,18 @@ class Client {
data = await response.json();
} else {
data = {
message: text
message: await response.text()
};
}

if (400 <= response.status) {
throw new AppwriteException(data?.message, response.status, data?.type, text);
let responseText = '';
if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') {
responseText = JSON.stringify(data);
} else {
responseText = data?.message;
}
throw new AppwriteException(data?.message, response.status, data?.type, responseText);
}

const cookieFallback = response.headers.get('X-Fallback-Cookies');
Expand Down
1 change: 1 addition & 0 deletions src/enums/credit-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export enum CreditCard {
Visa = 'visa',
MIR = 'mir',
Maestro = 'maestro',
Rupay = 'rupay',
}
1 change: 1 addition & 0 deletions src/services/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class Databases extends Service {
* collection resource using either a [server
* integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
* API or directly from your database console.
*
*
* @param {string} databaseId
* @param {string} collectionId
Expand Down