feat(core): switch to native fetch API for all HTTP requests

This commit is contained in:
2025-07-27 07:19:34 +00:00
parent fb30c6f4e3
commit c9fab7def2
8 changed files with 85 additions and 54 deletions

View File

@@ -161,7 +161,7 @@ export class BunqAccount {
}
// Sandbox user creation doesn't require authentication
const response = await plugins.smartrequest.request(
const response = await fetch(
'https://public-api.sandbox.bunq.com/v1/sandbox-user-person',
{
method: 'POST',
@@ -170,12 +170,18 @@ export class BunqAccount {
'User-Agent': 'bunq-api-client/1.0.0',
'Cache-Control': 'no-cache'
},
requestBody: '{}'
body: '{}'
}
);
if (response.body.Response && response.body.Response[0] && response.body.Response[0].ApiKey) {
return response.body.Response[0].ApiKey.api_key;
if (!response.ok) {
throw new Error(`Failed to create sandbox user: HTTP ${response.status}`);
}
const responseData = await response.json();
if (responseData.Response && responseData.Response[0] && responseData.Response[0].ApiKey) {
return responseData.Response[0].ApiKey.api_key;
}
throw new Error('Failed to create sandbox user');