1.2 KiB
1.2 KiB
SmartRequest API Update - January 2025
Context
The @push.rocks/smartrequest package (v4.2.1) uses a new chainable API that replaced the old function-based API.
Changes Made
Old API (v2.x)
const response = await plugins.smartrequest.request(url, {
headers: this.headers,
method: 'GET',
queryParams: { key: value }
});
const data = response.body;
New API (v4.x)
const requestBuilder = plugins.smartrequest.SmartRequest.create()
.url(url)
.headers(this.headers)
.query({ key: value });
const response = await requestBuilder.get();
const data = await response.json();
Key Differences
- Request Creation: Use
SmartRequest.create()
instead of direct function call - Chainable Methods: Configure requests with
.url()
,.headers()
,.query()
- HTTP Methods: Use
.get()
,.post()
,.delete()
etc. instead of method parameter - Response Parsing: Call
.json()
on response to get parsed data (was.body
before)
Files Updated
ts/classes.giteaassets.ts
- Updated thegetFiles()
method to use new API
Testing
All tests pass successfully, including the GiteaAssets tests that fetch real data from code.foss.global.