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

Chat with pdf ( Work in progress ) #326

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Add wrapper for axios get
redoC-A2k committed Apr 10, 2024
commit f7f17cb753f5a219eab51710a7e3e93601bdc844
29 changes: 29 additions & 0 deletions JS/wasm/crates/apis/src/http/shims/index.js
Original file line number Diff line number Diff line change
@@ -298,6 +298,35 @@ const requestToHandler = (input) => {
}
};

globalThis.axios = {
get: async (url) => {
try {
let response = await fetch(url, {
method: "GET",
});
try {
let body = JSON.parse(response.body);
response.body = body;
return response;
} catch (error) {
return response;
}
} catch (error) {
console.log("error occured");
return error;
}
},
post: async (url, data) => {
return fetch(url, {
method: "POST",
body: JSON.stringify(data),
headers: {
"Content-Type": "application/json",
},
});
},
};

globalThis.entrypoint = requestToHandler;
globalThis.result = {};
globalThis.error = null;
11 changes: 11 additions & 0 deletions JS/wasm/examples/hono-fetch/src/index.js
Original file line number Diff line number Diff line change
@@ -54,4 +54,15 @@ app.get('/get', async (c) => {
}
})

app.get('/axiosget', async (c) => {
try {
let repsonse = await axios.get('https://jsonplaceholder.typicode.com/todos/1');
return c.json(repsonse);
} catch (error) {
console.log("error occured")
writeOutput(error)
return c.json(error);
}
})

app.fire()