restructured - added data and inventory routes/controllers
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
// controllers/itemLookup.js
|
||||
import fetch from "node-fetch";
|
||||
import fetchEbayToken from "../utils/fetchEbayToken.js"; // Adjust the import path according to your project structure
|
||||
|
||||
const itemLookup = async (req, res) => {
|
||||
const productCode = req.body.productCode;
|
||||
export const itemLookup = async (req, res) => {
|
||||
const productCode = req.query.productCode;
|
||||
const oauthToken = await fetchEbayToken();
|
||||
console.log(productCode);
|
||||
try {
|
||||
@@ -22,15 +21,14 @@ const itemLookup = async (req, res) => {
|
||||
throw new Error("Failed to fetch data from eBay Browse API");
|
||||
|
||||
const data = await response.json();
|
||||
const price = [];
|
||||
data.itemSummaries.forEach((item) => {
|
||||
console.log(item.price, item.condition);
|
||||
price.push(item.price, item.condition);
|
||||
});
|
||||
|
||||
res.status(200).send("Data fetched successfully");
|
||||
res.status(200).send(price);
|
||||
} catch (error) {
|
||||
console.error("Error fetching data from eBay Browse API:", error);
|
||||
res.status(500).send("Internal Server Error");
|
||||
}
|
||||
};
|
||||
|
||||
export default itemLookup;
|
||||
0
api/controllers/inventoryController.js
Normal file
0
api/controllers/inventoryController.js
Normal file
Reference in New Issue
Block a user