mirror of
https://github.com/logos-storage/logos-storage-js.git
synced 2026-01-04 22:43:08 +00:00
Fix spr endpoint
This commit is contained in:
parent
e943a2ffa9
commit
711c4d6951
@ -308,7 +308,7 @@ const node = await codex.node;
|
||||
|
||||
Get Node's SPR
|
||||
|
||||
- returns Promise<string>
|
||||
- returns Promise<[CodexSpr](./src/node/types.ts#L1)>
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ describe("debug", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a success when trying to setup the log level with a correct value", async (t) => {
|
||||
it("returns a success when trying to setup the log level with a correct value", async () => {
|
||||
const mockResponse = {
|
||||
ok: true,
|
||||
status: 200,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Api } from "../api/config";
|
||||
import type { SafeValue } from "../async";
|
||||
import { Fetch } from "../fetch-safe/fetch-safe";
|
||||
import { Promises } from "../promise-safe/promise-safe";
|
||||
import type { CodexSpr } from "./types";
|
||||
|
||||
export class CodexNode {
|
||||
readonly url: string;
|
||||
@ -32,18 +32,12 @@ export class CodexNode {
|
||||
/**
|
||||
* Get Node's SPR
|
||||
*/
|
||||
async spr(): Promise<SafeValue<string>> {
|
||||
async spr(): Promise<SafeValue<CodexSpr>> {
|
||||
const url = this.url + Api.config.prefix + "/spr";
|
||||
|
||||
const res = await Fetch.safe(url, {
|
||||
return Fetch.safeJson(url, {
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
if (res.error) {
|
||||
return res;
|
||||
}
|
||||
|
||||
return await Promises.safe(res.data.text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
3
src/node/types.ts
Normal file
3
src/node/types.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export type CodexSpr = {
|
||||
spr: string;
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user