tests & image-request on google & inspirobot & front
This commit is contained in:
@@ -10,14 +10,12 @@ export async function searchAndResizeImage(query) {
|
||||
const imageUrl = data.items[0].link;
|
||||
console.log('Image URL:', imageUrl);
|
||||
return imageUrl;
|
||||
} else {
|
||||
console.error('No image found.');
|
||||
return "";
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching image:', error);
|
||||
return "";
|
||||
}
|
||||
console.error('No image found.');
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,3 +1,6 @@
|
||||
export * from './authentication'
|
||||
export * from './user'
|
||||
export * from './image-request'
|
||||
export * from './room'
|
||||
export * from './item'
|
||||
export * from './inspirobot'
|
||||
|
15
src/api/inspirobot.js
Normal file
15
src/api/inspirobot.js
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
export const findInspiration = async () => {
|
||||
|
||||
try {
|
||||
const url = 'https://corsproxy.io/?https://inspirobot.me/api?generate=true'
|
||||
const response = await fetch(url);
|
||||
|
||||
const pictureUrl = await response.text();
|
||||
console.log(pictureUrl);
|
||||
return pictureUrl
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
return "";
|
||||
}
|
25
src/api/item.js
Normal file
25
src/api/item.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import axios from "axios";
|
||||
|
||||
|
||||
|
||||
export const getItem = async (_id) => {
|
||||
try {
|
||||
const response = await axios.get("/item", {_id});
|
||||
console.log(response.data)
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.log("ERROR", error.response.data)
|
||||
return error.response.data;
|
||||
}
|
||||
};
|
||||
|
||||
export const getItems = async () => {
|
||||
try {
|
||||
const response = await axios.get("/item", {});
|
||||
console.log(response.data)
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.log("ERROR", error.response.data)
|
||||
return error.response.data;
|
||||
}
|
||||
};
|
@@ -2,7 +2,19 @@ import axios from "axios";
|
||||
|
||||
|
||||
|
||||
export const getRoom = async () => {
|
||||
|
||||
export const getRoom = async (_id) => {
|
||||
try {
|
||||
const response = await axios.get("/room", {_id});
|
||||
console.log(response.data)
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.log("ERROR", error.response.data)
|
||||
return error.response.data;
|
||||
}
|
||||
};
|
||||
|
||||
export const getRooms = async () => {
|
||||
try {
|
||||
const response = await axios.get("/room", {});
|
||||
console.log(response.data)
|
||||
|
Reference in New Issue
Block a user