簡體   English   中英

如何使用 hashmap 在 javascript 中存儲 JSON

[英]How to store JSON in javascript using hashmap

我使用了 shrtcode api,但我不知道如何存儲它的數據。

var requestOptions = {
method: 'GET',
redirect: 'follow'
};
fetch("https://api.shrtco.de/v2/shorten?url=www.google.com", requestOptions)//api
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
 }
 Response
 ok true
 result 
 code             "fQdPc"
 short_link       "shrtco.de/fQdPc"
 full_short_link      "https://shrtco.de/fQdPc"
 short_link2          "9qr.de/fQdPc"
 full_short_link2  "https://9qr.de/fQdPc"
 short_link3          "shiny.link/fQdPc"
 full_short_link3  "https://shiny.link/fQdPc"
 share_link       "shrtco.de/share/fQdPc"
 full_share_link      "https://shrtco.de/share/fQdPc"
 original_link    "http://www.google.com"

如何打印或存儲“full_short_link”的值?

像這樣?

 const doStuff = async () => { try { const res = await fetch('https://api.shrtco.de/v2/shorten?url=www.google.com'); const json = await res.json(); console.log('full_short_link', json.result.full_short_link); } catch (err) { console.error(err); } }; doStuff();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM