 |
[PHP]
สอบถามการเขียน javascript นับจำนวนข้อมูลเเยกตามเงื่อนหน่อยครับ |
|
 |
|
|
 |
 |
|
Code (JavaScript)
01. const fetchApi = async (url) => {
02. try {
03. let response = await fetch(url, {
04. method: 'GET' ,
05. headers: {
06. "Content-type" : "application/json; charset=UTF-8"
07. }
08. });
09. let data = await response.json();
10. return data;
11. } catch (error) {
12. return error;
13. }
14. }
15.
17. .then(data => {
18. let result = data.reduce((previousValue, currentValue, currentIndex, array) => currentValue.type == 'hybrid' ? previousValue + 1 : previousValue, 0);
19. console.log(result);
20. }). catch (error => {
21. console.log(error)
22. });
23.
24.
|
 |
 |
 |
 |
Date :
2022-01-05 13:16:29 |
By :
Guest |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|