Я хочу сохранить данные в файл stati c 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."
}
]