【发布时间】:2021-05-29 10:43:38
【问题描述】:
let url = "/"
fetch(url, {
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
}
})
.then(resp => resp.json())
.then(data => {
setToken(1);
})
.catch(function(err) {
console.log('Fetch Error :-S', err);
});
我有代理OK:http://localhost:3001/people"
我已经配置了这个 json-server
{
"people": [
{
"id": "1",
"name": "gustavo",
"pass": "gustavo",
"days": {
"23/02/2021": [
{
"arrive": "09:00",
"lunchstart": "12:00",
"lunchend": "13:00",
"exit": "17:00"
}
],
"24/02/2021": [
{
"arrive": "09:00",
"lunchstart": "11:30",
"lunchend": "13:00",
"exit": "17:00"
}
]
}
}
]
}
如果使用“/1”就可以了。如何只使用“/”?
我也可以使用 INSOMNIA 或 POSTMAN,它适用于 /people
【问题讨论】:
标签: javascript reactjs get fetch json-server