feat(core): switch to native fetch API for all HTTP requests
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user