Skip to content

Commit

Permalink
fix: merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BastinJafari committed Sep 21, 2021
1 parent c7569cf commit 4121adb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
6 changes: 3 additions & 3 deletions packages/jinajs/src/jinaClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios, { AxiosInstance } from "axios";
import { AnyObject } from "index";
import { serializeRequest, serializeResponse } from "./serializer";
import MockedClient from './MockedClient'
import {
Expand Down Expand Up @@ -62,11 +61,12 @@ export class JinaClient<IRequest = AnyObject ,IResponse = AnyObject> {
documents: RawDocumentData[],
parameters: AnyObject
): Promise<{ results: SimpleResults[]; queries: SimpleQueries }> {
const requestBody = await this.serializeRequest(documents, this.jinaVersion,parameters);
console.log(parameters)
const requestBody = await this.serializeRequest(documents);
console.log("request body:", requestBody);
const response = await this.client.post("search", requestBody);
console.log("response:", response);
return this.serializeResponse(response.data, this.jinaVersion);
return this.serializeResponse(response.data);
}

}
2 changes: 1 addition & 1 deletion packages/jinajs/src/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function serializeResponse(
});
const { matches } = doc;
results.push(
matches.map(({ scores, text, uri, mimeType }: any) => {
matches.map(({ scores, text, uri, mimeType, tags }: any) => {
const score = scores.values
? scores.values?.value
: scores.score?.value;
Expand Down
11 changes: 2 additions & 9 deletions packages/jinajs/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export const fileToBase64 = (file: File): Promise<string> =>

export function urlToBase64(url: string) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
const xhr = new XMLHttpRequest();
xhr.responseType = "arraybuffer";
xhr.open("GET", `${url}`);

xhr.onload = function () {
var base64, binary, bytes, mediaType;
let base64, binary, bytes, mediaType;

bytes = new Uint8Array(xhr.response);
//NOTE String.fromCharCode.apply(String, ...
Expand All @@ -42,13 +42,6 @@ export function urlToBase64(url: string) {
});
}

new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result as string);
reader.onerror = (error) => reject(error);
});

export const schemaToMock = (schema: OpenAPIV3.SchemaObject) => {
let mockedResponse = {
...schema?.properties
Expand Down

0 comments on commit 4121adb

Please sign in to comment.