【发布时间】:2021-09-20 19:26:32
【问题描述】:
我有这个功能来保存和获取数据: 保存:
try {
const request = new Request('https://yandexmap-96969-default-rtdb.firebaseio.com/locations.json', {
method: 'post',
body: JSON.stringify(addNewLocation)
})
const response = await fetch(request)
window.location.reload()
return await response.json()
} catch (error) {
alert('Try again: ', error)
}
//to get:
try {
const request = new Request('https://yandexmap-96969-default-rtdb.firebaseio.com/locations.json', { method: 'get'})
const response = await fetch(request)
return await response.json()
} catch (error) {
alert('Try again: ', error)
}
当我使用“delete”而不是“get”时,它会完全删除位置文件夹,但是当我在链接末尾使用带有键的链接时,会出现错误
【问题讨论】:
-
您好,如果我的回答对您有帮助,您可以点击对勾图标接受。 What should I do when someone answers 否则请随时询问更多问题。
标签: javascript node.js firebase rest firebase-realtime-database