Я хочу, чтобы сохранить данные в файл статической JSON, сидя на моем сервере с помощью Fetch запроса POST.
Возможно ли это сделать? Если так что любые советы или рекомендации будут оценены
Мой код Javascript, чтобы попытаться сохранить данные в мой файл JSON.
fetch('link-data.json', {
method:'POST',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-type':'application/json'
},
body:JSON.stringify({
id:3,
title:website_title,
url:www.example.com,
description:Hi_there_im_a_description
})
})
.then((res) => res.json())
.then((data) => console.log(data))
Мой файл JSON Я хочу, чтобы сохранить данные.
[
{
id: 0,
title: Twitter. It's what's happening.,
url: https://twitter.com/?lang=en,
description: From breaking news and entertainment to sports and politics, get the full story with all the live commentary.
},
{
id: 1,
title: Netflix - Watch TV Shows Online, Watch Movies Online,
url: https://www.netflix.com/,
description: Watch Netflix movies & TV shows online or stream right to your smart TV, game console, PC, Mac, mobile, tablet and more.
},
{
id: 2,
title: Facebook - Log In or Sign Up,
url: https://www.facebook.com/,
description: Create an account or log into Facebook. Connect with friends, family and other people you know. Share photos and videos, send messages and get updates.
}
]