I want to get customer details/order details in my application from the shopify store. How can i do that?
Hi @rabinparajuli ,
Thanks for reaching out here! I’d like to gather a bit more context so we understand what you’re after.
What application are you referring to? Would you perhaps be able to explain abit more as to what you’re wanting to achieve?
We can go from there!
Hi Nia,
Thank you for reaching out to me. Well the application i am developing is for delivery. So i want to get customer details on my application once they have purchased something from the store.
Hello Nia,
i tried with this code but didn’t work for me.
// src/components/OrderList.js
import React, { useEffect, useState } from ‘react’;
import shopifyApi from ‘./Shopifyapi’;
function OrderList() {
const [orderDetails, setOrderDetails] = useState();
useEffect(() => {
shopifyApi.get(‘/admin/api/2023-10/orders.json’)
.then(response => {
// Extract the ‘id’ property from each order object
const orderIds = response.data.orders.map(order => order.id);
setOrderDetails(orderIds);
})
.catch(error => {
console.error(‘Error fetching order data:’, error);
});
}, );
export default OrderList;