-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ch[#161862452] Get sales record from api
- Loading branch information
1 parent
210b161
commit 2868bfc
Showing
3 changed files
with
33 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const getSales = () => { | ||
fetch('https://newstoremanager.herokuapp.com/api/v1/sales', { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
accesstoken: localStorage.accesstoken, | ||
}, | ||
}) | ||
.then(res => res.json()) | ||
.then((data) => { | ||
let output; | ||
data.forEach((sales) => { | ||
output = ` | ||
<tr> | ||
<td>${sales.created_at}</td> | ||
<td>${sales.productname}</td> | ||
<td>${sales.quantity}</td> | ||
<td>${sales.price}</td> | ||
<td>${sales.attendant_id}</td> | ||
</tr> | ||
`; | ||
document.getElementById('sales-record').innerHTML += output; | ||
}); | ||
}); | ||
}; | ||
|
||
window.onload = getSales(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters