Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect to Pieces OS Using provided Connector.Api endpoint #58

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions src/app/utils/Connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,17 @@ import * as Pieces from "@pieces.app/pieces-os-client";

// ============================ [/connect]=============================//
const tracked_application = {
name: Pieces.ApplicationNameEnum.Brave,
name: Pieces.ApplicationNameEnum.Unknown,
version: '0.0.1',
platform: Pieces.PlatformEnum.Macos,
}
// TODO: this will need to be updated once we are further along with the connector work.
export async function connect(): Promise<JSON> {

const url: string = 'http://localhost:1000/connect';
const options: {method: string, body: string} = {
method: 'POST',
body: JSON.stringify({ application: tracked_application}
),
}

let _output: Promise<JSON>;

try {
const response: Response = await fetch(url, options);
const data: Promise<JSON> = await response.json();
_output = data;
return _output;
} catch (e) {
console.error(e);
}

const connectorApi = new Pieces.ConnectorApi();
const response = await connectorApi.connect({
seededConnectorConnection: { application: tracked_application },
});
// console.log(response); you can log response just to confirm
return JSON.parse(JSON.stringify(response));
}
// ============================ [.end /connect]=============================//
Loading