1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

changes in search paths & type

This commit is contained in:
Jernej Pregelj 2018-10-29 16:38:23 +01:00
parent 8c4ba81589
commit af376eb7ee
2 changed files with 35 additions and 2 deletions

View File

@ -36,7 +36,7 @@ export default class Aquarius {
public async queryMetadata(query): Promise<any[]> {
const result = await AquariusConnectorProvider.getConnector().post(
this.url + "/api/v1/aquarius/assets/metadata/query",
this.url + "/api/v1/aquarius/assets/ddo/query",
JSON.stringify(query))
.then((response: any) => {
if (response.ok) {
@ -45,7 +45,25 @@ export default class Aquarius {
Logger.log("Failed: ", response.status, response.statusText)
})
.catch((error) => {
Logger.error("Error fetching querying metdata: ", error)
Logger.error("Error fetching querying metadata: ", error)
})
return result
}
public async queryMetadataByText(query): Promise<any[]> {
const result = await AquariusConnectorProvider.getConnector().get(
this.url + "/api/v1/aquarius/assets/ddo/query",
JSON.stringify(query))
.then((response: any) => {
if (response.ok) {
return response.json()
}
Logger.log("Failed: ", response.status, response.statusText)
})
.catch((error) => {
Logger.error("Error fetching querying metadata: ", error)
})
return result

View File

@ -1,4 +1,5 @@
import fetch from "node-fetch"
import URL from "url"
export default class AquariusConnector {
@ -11,4 +12,18 @@ export default class AquariusConnector {
},
})
}
public get(url, payload) {
const fullUrl = new URL(url)
for (const key of Object.keys(payload)) {
fullUrl.searchParams.append(key, payload[key])
}
return fetch(fullUrl, {
method: "GET",
body: null,
headers: {
"Content-type": "application/json",
},
})
}
}