I have a JSON like this. So, how to get url type basic: https://obs.line-scdn.net/0hLbl4V2I5E01RTTg_zdxsGmMfFC0_IQhTc3lCeS0dDiEgNQxHPX0IK3wfH3R9ehEaPS9ceH0eSg/L100x100 \\ ?
Image :[ {
"id": 1,
"thumbnail": "[{\"url\":\"https://obs.line-scdn.net/0hLbl4V2I5E01RTTg_zdxsGmMfFC0_IQhTc3lCeS0dDiEgNQxHPX0IK3wfH3R9ehEaPS9ceH0eSg/L100x100\",\"width\":100},{\"url\":\"https://obs.line-scdn.net/0hLbl4V2I5E01RTTg_zdxsGmMfFC0_IQhTc3lCeS0dDiEgNQxHPX0IK3wfH3R9ehEaPS9ceH0eSg/L200x200\",\"width\":200},{\"url\":\"https://obs.line-scdn.net/0hLbl4V2I5E01RTTg_zdxsGmMfFC0_IQhTc3lCeS0dDiEgNQxHPX0IK3wfH3R9ehEaPS9ceH0eSg/L500x500\",\"width\":500},{\"url\":\"https://obs.line-scdn.net/0hLbl4V2I5E01RTTg_zdxsGmMfFC0_IQhTc3lCeS0dDiEgNQxHPX0IK3wfH3R9ehEaPS9ceH0eSg/L1000x1000\",\"width\":1000}]",
"category": {
"id": 2,
"title": "title"
},
"title": "look good",
"rank": 6,
"is_new": false,
"is_pr": false
}]
var{ data } = this.props;
const image = data ? data.thumbnail : "";
const convert = image ? image.replace("[","").replace("]", "") : "";
let img = "";
if (convert.length !== 0) {
img = convert ? JSON.parse(convert).url :"";
}
console.log(convert)
const imageStyle = {
backgroundImage: `url(${img})`,
};`
You need to deploy the web api which will return you this json object,After deploying you will get the URL . so you can fetch this in react component using fetch(urlForApi).then(res=>res.json()).then(data=>HereIsTheData)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.