UNPKG

qdrant

Version:

Qdrant vector search engine client library

42 lines (33 loc) 906 B
import fetch from "node-fetch"; export async function body_request(url,body,method){ method = method || "POST"; let fetch_spec = { method: method, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; if (body) fetch_spec.body = JSON.stringify(body); let response = await fetch(url, fetch_spec); try { const output = await response.json(); return [null,output]; } catch(ex) { const output = null; return [ex,output]; } } export async function url_request(url,params){ if (params) { url += "?" + new URLSearchParams(params).toString(); } let response = await fetch(url); try { const output = await response.json(); return [null,output]; } catch(ex) { const output = null; return [ex,output]; } }