MCPcopy
hub / github.com/numbersprotocol/nit / httpPost

Function httpPost

src/commitdb.ts:103–122  ·  view source on GitHub ↗
(url, data, accessToken=null)

Source from the content-addressed store, hash-verified

101}
102
103export async function httpPost(url, data, accessToken=null) {
104 const formData = new FormData();
105 for (const key of Object.keys(data)) {
106 formData.append(key, data[key] ? data[key] : "");
107 }
108
109 //const authBase64 = Buffer.from(`${ProjectId}:${ProjectSecret}`).toString('base64');
110 const requestConfig = {
111 "headers": {
112 //"Authorization": `Bearer ${authBase64}`,
113 ...formData.getHeaders(),
114 },
115 }
116 if (accessToken != null) {
117 requestConfig.headers.Authorization = `Bearer ${accessToken}`;
118 }
119 const r = await axios.post(url, formData, requestConfig);
120 const returnedData = r.data;
121 return returnedData;
122}
123
124export async function push(commitDbUpdateUrl: string, assetCid: string, commitDbCommitUrl: string) {
125 const data = {

Callers 2

updateFunction · 0.85
pushFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected