|
@@ -1,11 +1,11 @@
|
|
const getGQL = url => async (query, variables) => {
|
|
const getGQL = url => async (query, variables) => {
|
|
try {
|
|
try {
|
|
- const token = localStorage.token;
|
|
|
|
|
|
+ const token = localStorage.token ? localStorage.token : '';
|
|
const res = await fetch(url, {
|
|
const res = await fetch(url, {
|
|
method: 'POST',
|
|
method: 'POST',
|
|
headers: {
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
- Authorization: 'Bearer ' + token ? token : '',
|
|
|
|
|
|
+ Authorization: 'Bearer ' + token,
|
|
},
|
|
},
|
|
body: JSON.stringify({ query, variables }),
|
|
body: JSON.stringify({ query, variables }),
|
|
});
|
|
});
|
|
@@ -160,14 +160,11 @@ const orderById = async _id => {
|
|
const { data } = await gql(
|
|
const { data } = await gql(
|
|
`query findById($id:String){
|
|
`query findById($id:String){
|
|
OrderFindOne (query:$id){
|
|
OrderFindOne (query:$id){
|
|
- _id createdAt name price description images {
|
|
|
|
- url
|
|
|
|
- }
|
|
|
|
|
|
+ _id createdAt
|
|
}
|
|
}
|
|
}`,
|
|
}`,
|
|
{ id: JSON.stringify([{ _id }]) },
|
|
{ id: JSON.stringify([{ _id }]) },
|
|
);
|
|
);
|
|
-
|
|
|
|
return data.OrderFindOne;
|
|
return data.OrderFindOne;
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.error(e);
|
|
console.error(e);
|