-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
88 lines (86 loc) · 2.08 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var url='http://localhost/app-contact/test0.php'
var url1='http://localhost/app-contact/loginsearch.php'
var url2='http://localhost/app-contact/addmeal.php'
var url3='http://localhost/app-contact/listmeal.php'
var url4='http://localhost/app-contact/showdatabase.php'
var url5='http://192.168.43.40/app-contact/getdatebase.php'
const fetch=require('node-fetch')
function searchlogin(){
fetch(url1, {
method: 'post',
headers: {
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
},
body: 'name='+name1
})
.then(res=>res.json())
.then(function (data) {
console.log('Request succeeded with JSON response', data);
})
.catch(function (error) {
console.log('Request failed', error);
});
}
function login(){
fetch(url3, {
method: 'post',
headers: {
"Content-type": "application/x-www-form-urlencoded;"
},
body: 'dbname=buct&dbtable=firstmeal'
})
.then(res=>res.json())
.then(function (data) {
console.log(data);
})
.catch(function (error) {
console.log('Request failed', error);
});
}
function addmeal(){
fetch(url2, {
method: 'post',
headers: {
"Content-type": "application/x-www-form-urlencoded;charset=utf8'"
},
body: 'university=buct&canteenname=firstmeal&name=zhong碗宽面&price=10&feature=全体供应'
})
.then(res=>res.text())
.then(function (data) {
console.log(data);
})
.catch(function (error) {
console.log('Request failed', error);
});
}
//login()
function gettablename(){
fetch(url5)
.then(res=>res.json())
.then(function (data) {
console.log(data);
})
.catch(function (error) {
console.log('Request failed', error);
});
}
let namse='buct'
function tablename(){
fetch(url4, {
method: 'post',
headers: {
"Content-type": "application/x-www-form-urlencoded;charset=utf8'"
},
body: 'dbname='+namse
})
.then(res=>res.json())
.then(function (data) {
console.log(data);
})
.catch(function (error) {
console.log('Request failed', error);
});
}
login()
//fetch(url).then(res=>res.json()).then(data=>console.log(data))