Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
order-management-react
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ascend
order-management-react
Commits
d5f3e16d
Commit
d5f3e16d
authored
May 14, 2021
by
Alex Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[AFP-135]
🗃
Add paginated & filtered orders method to orders service (
@asegers
)
parent
b1350762
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
OrderService.ts
src/services/OrderService.ts
+20
-1
No files found.
src/services/OrderService.ts
View file @
d5f3e16d
import
orderList
from
'./mock-order-data'
import
{
Order
}
from
'Order'
;
import
{
OrdersRequestBody
}
from
'ManagerRequests'
import
Axios
,
{
AxiosError
}
from
'axios'
import
{
sleep
}
from
'utils'
const
BASE_PATH
=
'/api/orders'
export
const
allOrders
=
()
=>
{
const
apiUrl
=
'http://localhost:8080/api/orders'
;
...
...
@@ -10,8 +14,23 @@ export const orderById = (apiUrl: string) => {
return
fetch
(
apiUrl
).
then
((
response
)
=>
response
.
json
())
}
export
const
orders
=
async
(
body
:
OrdersRequestBody
):
Promise
<
Order
[]
>
=>
{
try
{
console
.
log
(
JSON
.
stringify
(
body
,
null
,
3
))
debugger
await
sleep
(
1000
)
const
response
=
await
Axios
.
post
(
`
${
BASE_PATH
}
/filtered`
,
body
)
console
.
log
(
response
.
data
)
return
response
.
data
;
}
catch
(
error
)
{
const
{
response
}
=
error
as
AxiosError
;
console
.
error
(
'`OrderService#orders` FAILED TO FETCH ORDERS: '
,
response
)
return
[];
}
}
export
default
{
allOrders
,
orderById
orderById
,
orders
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment