I have a web app where you select documents and display them. The document tree is generated from a sql table with a one to many relationship on itself.
What it looks like on the frontend
This tree is generated from an sql table with the following columns :
(page_id, position, title, version, parent_id)
The sql table in question
I can already query this table and retrieve a tree like the following :
{
"position": 0,
"version": 51,
"children": [
{
"position": 0,
"version": 51,
"children": [
{
"position": 0,
"version": 51,
"parentId": "2",
"id": "5",
"name": "Page 1"
},
{
"position": 1,
"version": 51,
"parentId": "2",
"id": "6",
"name": "Page 2"
},
{
"position": 2,
"version": 51,
"parentId": "2",
"id": "7",
"name": "Page 3"
}
],
"parentId": "1",
"id": "2",
"name": "Category 1"
},
{
"position": 1,
"version": 51,
"children": [
{
"position": 0,
"version": 51,
"parentId": "3",
"id": "8",
"name": "Page 4"
},
{
"position": 1,
"version": 51,
"parentId": "3",
"id": "9",
"name": "Page 5"
},
{
"position": 2,
"version": 51,
"parentId": "3",
"id": "10",
"name": "Page 6"
},
{
"position": 3,
"version": 51,
"children": [
{
"position": 0,
"version": 51,
"parentId": "4",
"id": "11",
"name": "Page 7"
},
{
"position": 1,
"version": 51,
"parentId": "4",
"id": "12",
"name": "Page 8"
},
{
"position": 2,
"version": 51,
"parentId": "4",
"id": "13",
"name": "Page 9"
}
],
"parentId": "3",
"id": "4",
"name": "Category 3"
}
],
"parentId": "1",
"id": "3",
"name": "Category 2"
}
],
"parentId": "0",
"id": "1",
"name": "Doc Root"
}
This is the entity class :
#Entity
#Table
#AllArgsConstructor
#NoArgsConstructor
#Getter
#Setter
#JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Node {
#Id
#JsonProperty("id")
private Long pageId;
public String getPageId() {
return pageId.toString();
}
#ManyToOne(cascade = CascadeType.ALL)
#JsonBackReference
#JoinColumn(name = "parent_id")
private Node parent;
public String getParentId() {
return parent.getPageId();
}
private Long position;
private Long version;
#JsonProperty("name")
private String title;
#OneToMany(mappedBy = "parent")
#OrderBy(value = "position asc")
#JsonManagedReference
private List<Node> children;
}
What I am trying to do is to retrieve only parts of this tree depending on the selected nodes. For reference, with the above selections, I'd like to receive a tree with the following content :
{
"position": 0,
"version": 51,
"children": [
{
"position": 0,
"version": 51,
"children": [
{
"position": 0,
"version": 51,
"parentId": "2",
"id": "5",
"name": "Page 1"
},
{
"position": 1,
"version": 51,
"parentId": "2",
"id": "6",
"name": "Page 2"
},
{
"position": 2,
"version": 51,
"parentId": "2",
"id": "7",
"name": "Page 3"
}
],
"parentId": "1",
"id": "2",
"name": "Category 1"
},
{
"position": 1,
"version": 51,
"children": [
{
"position": 3,
"version": 51,
"children": [
{
"position": 0,
"version": 51,
"parentId": "4",
"id": "11",
"name": "Page 7"
},
{
"position": 1,
"version": 51,
"parentId": "4",
"id": "12",
"name": "Page 8"
},
{
"position": 2,
"version": 51,
"parentId": "4",
"id": "13",
"name": "Page 9"
}
],
"parentId": "3",
"id": "4",
"name": "Category 3"
}
],
"parentId": "1",
"id": "3",
"name": "Category 2"
}
],
"parentId": "0",
"id": "1",
"name": "Doc Root"
}
Related
QBOnline API: Problems with overriding Sales Tax - passed in values not respected on Invoice (AST seems to override my override)
Hi all,
Yes, I'm new to the API. Diving in head first! :)
I'm trying to troubleshoot a problem with my app. It's submitting new Invoices to the QBOnline API, and passing in all the line item information. We aren't trying to use the AST system - so I was trying to set the override values. (Documentation: https://developer.intuit.com/app/developer/qbo/docs/workflows/manage-sales-tax-for-us-locales#specifying-sales-tax)
I think that I am providing the values correctly, but the system is still calculating it's own sales tax amount.
Target API URL:
https://sandbox-quickbooks.api.intuit.com/v3/company/4620816365232674520/Invoice?minorversion=4
Here's an example of the object we are passing in (edited for privacy, expanded for human readability):
{
"BillAddr": {
"City": "AnywhereVille",
"Country": "USA",
"CountrySubDivisionCode": "CA",
"Line1": "",
"Line2": "Customer Name LLP",
"Line3": "45 E. Pacific Coast Highway",
"Line4": "",
"PostalCode": "90804"
},
"CustomField": [{
"DefinitionId": "1",
"Name": "P.O. Number",
"StringValue": "",
"Type": "StringType"
}, {
"DefinitionId": "2",
"Name": "Sales Rep",
"StringValue": "TY",
"Type": "StringType"
}],
"CustomerMemo": {
"value": "Pay your invoice online at: ..."
},
"CustomerRef": {
"value": "60"
},
"DocNumber": "11111",
"DueDate": "2022-08-01",
"Line": [{
"Amount": 576,
"Description": "",
"DetailType": "SalesItemLineDetail",
"LineNum": 1,
"SalesItemLineDetail": {
"ClassRef": {
"name": "3 Studios",
"value": "1111111111111"
},
"ItemRef": {
"name": "16GBUSBFLASH",
"value": "21"
},
"Qty": 48,
"TaxCodeRef": {
"value": "TAX"
},
"UnitPrice": 12
}
}, {
"Amount": 168,
"Description": "",
"DetailType": "SalesItemLineDetail",
"LineNum": 4,
"SalesItemLineDetail": {
"ClassRef": {
"name": "3 Studios",
"value": "1111111111111"
},
"ItemRef": {
"name": "DVDMEDIA",
"value": "23"
},
"Qty": 12,
"TaxCodeRef": {
"value": "TAX"
},
"UnitPrice": 14
}
}, {
"Amount": 600,
"Description": "",
"DetailType": "SalesItemLineDetail",
"LineNum": 6,
"SalesItemLineDetail": {
"ClassRef": {
"name": "3 Studios",
"value": "1111111111111"
},
"ItemRef": {
"name": "DIGITALDEL30",
"value": "25"
},
"Qty": 12,
"TaxCodeRef": {
"value": "TAX"
},
"UnitPrice": 50
}
}],
"SalesTermRef": {
"value": "8"
},
"TxnDate": "2022-08-01",
"TxnTaxDetail": {
"TaxLine": [{
"Amount": 130.98,
"DetailType": "TaxLineDetail",
"TaxLineDetail": {
"NetAmountTaxable": 576,
"PercentBased": true,
"TaxPercent": 0.0925,
"TaxRateRef": {
"value": "4"
}
}
}],
"TotalTax": 130.98,
"TxnTaxCodeRef": {
"value": "4"
}
}
}
This is my actual query:
const query = this.doctorsRepository.createQueryBuilder('doctor')
.innerJoinAndSelect('doctor.services', 'services')
await query.getMany();
This is the result:
[
{
"id": 3,
"created_at": "2021-09-09T14:11:09.779Z",
"updated_at": "2021-09-09T14:11:09.779Z",
"name": "Test Doctor Name",
"bio": "Test Doctor Bio",
"services": [
{
"id": 1,
"created_at": "2021-08-18T17:35:52.506Z",
"updated_at": "2021-08-18T17:35:52.506Z",
"title": "new service by me"
},
{
"id": 2,
"created_at": "2021-08-13T15:58:01.918Z",
"updated_at": "2021-08-13T15:58:01.918Z",
"title": "testing service creation at night again & again"
}
]
},
{
"id": 2,
"created_at": "2021-09-09T12:58:05.564Z",
"updated_at": "2021-09-09T13:47:37.299Z",
"name": "Doctor Name",
"bio": "Doctor Bio",
"services": [
{
"id": 26,
"created_at": "2021-08-13T08:47:07.941Z",
"updated_at": "2021-08-13T08:47:07.941Z",
"title": "service 26"
},
{
"id": 36,
"created_at": "2021-08-13T08:49:22.732Z",
"updated_at": "2021-08-13T08:49:22.732Z",
"title": "service 36"
},
{
"id": 1,
"created_at": "2021-08-08T19:18:26.056Z",
"updated_at": "2021-08-08T19:18:26.056Z",
"title": "service 1"
},
{
"id": 77,
"created_at": "2021-08-13T10:12:55.529Z",
"updated_at": "2021-08-13T10:12:55.529Z",
"title": "testy 10"
}
]
}]
As you see, I have Doctor & Service entity that Doctor entity has Many-to-Many relation with service entity. Everything is ok until here.
But I wanna filter result by services ids, I mean I have an array of ids like this:
const servicesArray = [1, 2]
And I wanna filter result by services ids. I tested many ways but I didn't get my answer.
Note: This code didn't solve my problem:
andWhere('services.id in (:...ids)', {
ids: servicesArray,
})
And for better understanding this is what I expect:
Items that filtered by services ids (item that has services with the id of 1 and 2);
[
{
"id": 3,
"created_at": "2021-09-09T14:11:09.779Z",
"updated_at": "2021-09-09T14:11:09.779Z",
"name": "Test Doctor Name",
"bio": "Test Doctor Bio",
"services": [
{
"id": 1,
"created_at": "2021-08-18T17:35:52.506Z",
"updated_at": "2021-08-18T17:35:52.506Z",
"title": "new service by me"
},
{
"id": 2,
"created_at": "2021-08-13T15:58:01.918Z",
"updated_at": "2021-08-13T15:58:01.918Z",
"title": "testing service creation at night again & again"
}
]
},
]
I also added :
query
.addSelect('COUNT(services.id)', 'services_count')
.groupBy('services.id')
.addGroupBy('doctor.id');
But the problem isn't solved, because addSelect doesn't work with getMany, it works with getRawMany.
I am trying to add two tables, in which first table contains all the video details, and in second table details of video seen by the user with user_id and video_id. I just want to add both the tables and it will show all the list of videos from first table but if the video is seen by the user, status will show 1 else 1.
Here is my query,
SELECT
videos.id, videos.lang_id, videos.medical_type_id, videos.name,
videos.description, videos.thumbnail, videos.video, videos.video_type,
videos.delete_status,
CASE
WHEN video_quews.user_id = $user_id
THEN $user_id
ELSE 'ok'
END AS user_id,
video_quews.video_id, video_quews.created_at,
CASE
WHEN video_quews.video_id = videos.id
THEN 1
ELSE 0
END AS status
FROM
videos
LEFT JOIN
video_quews ON videos.id = video_quews.video_id
ORDER BY
video_quews.video_id DESC
Currently, videos are repeating.
Please help me out
here is my response,
{
"message": "All related videos",
"status": "success",
"code": 200,
"videos": [
{
"id": "30",
"lang_id": "2",
"medical_type_id": "15",
"name": "Fracture",
"thumbnail": "thumbnail_images/1579869167.png",
"video": "videos/fracture.m4v",
"video_type": "2",
"delete_status": "1",
"user_id": "6",
"video_id": "30",
"created_at": "2021-03-04 23:29:50",
"status": "1"
},
{
"id": "16",
"lang_id": "2",
"medical_type_id": "14",
"name": "Electrocution",
"thumbnail": "thumbnail_images/1579698529.png",
"video": "videos/ELECTROCUTION.m4v",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "16",
"created_at": "2021-03-05 08:19:29",
"status": "1"
},
{
"id": "15",
"lang_id": "2",
"medical_type_id": "13",
"name": "Adult CPR & AED(Cardiac Arrest)",
"thumbnail": "thumbnail_images/1579698505.png",
"video": "videos/CPR1.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "15",
"created_at": "2021-03-05 08:18:38",
"status": "1"
},
{
"id": "14",
"lang_id": "2",
"medical_type_id": "12",
"name": "Choking",
"thumbnail": "thumbnail_images/1579698405.png",
"video": "videos/Choking.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "14",
"created_at": "2021-03-05 08:17:47",
"status": "1"
},
{
"id": "13",
"lang_id": "2",
"medical_type_id": "11",
"name": "Chest pain",
"thumbnail": "thumbnail_images/1579698381.png",
"video": "videos/CHESTPAIN.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "13",
"created_at": "2021-03-05 08:17:20",
"status": "1"
},
{
"id": "12",
"lang_id": "2",
"medical_type_id": "10",
"name": "Burns",
"thumbnail": "thumbnail_images/1579698360.png",
"video": "videos/Burns.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "12",
"created_at": "2021-03-05 08:16:39",
"status": "1"
},
{
"id": "11",
"lang_id": "2",
"medical_type_id": "9",
"name": "Breathing Difficulties",
"thumbnail": "thumbnail_images/1579698344.png",
"video": "videos/BreathingDifficulties.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "11",
"created_at": "2021-03-05 08:16:19",
"status": "1"
},
{
"id": "8",
"lang_id": "2",
"medical_type_id": "6",
"name": "Asthma",
"thumbnail": "thumbnail_images/1579698286.png",
"video": "videos/ASTHMA.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": "8",
"created_at": "2021-03-05 08:15:59",
"status": "1"
},
{
"id": "24",
"lang_id": "2",
"medical_type_id": "22",
"name": "Fits/Seizures",
"thumbnail": "thumbnail_images/1579698775.png",
"video": "videos/SEIZURES.m4v",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "26",
"lang_id": "2",
"medical_type_id": "24",
"name": "Sprain, strain",
"thumbnail": "thumbnail_images/1579698853.png",
"video": "videos/SPRAIN&STRAIN.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "28",
"lang_id": "2",
"medical_type_id": "26",
"name": "Disposing Glove",
"thumbnail": "thumbnail_images/1579698903.png",
"video": "videos/disposingglove.mp4",
"video_type": "1",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "31",
"lang_id": "2",
"medical_type_id": "8",
"name": "Bleeding",
"thumbnail": "thumbnail_images/1581498917.png",
"video": "videos/bleeding.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "18",
"lang_id": "2",
"medical_type_id": "16",
"name": "Gunshot Wound",
"thumbnail": "thumbnail_images/1579698550.png",
"video": "videos/Gunshot.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "20",
"lang_id": "2",
"medical_type_id": "18",
"name": "Hypoglycemia",
"thumbnail": "thumbnail_images/1579698684.png",
"video": "videos/Hypoglycemia.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "22",
"lang_id": "2",
"medical_type_id": "20",
"name": "Nose Bleeding",
"thumbnail": "thumbnail_images/1579698728.png",
"video": "videos/nosebleeding.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "25",
"lang_id": "2",
"medical_type_id": "23",
"name": "Snake Bite",
"thumbnail": "thumbnail_images/1579698801.png",
"video": "videos/SnakeBite.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "27",
"lang_id": "2",
"medical_type_id": "25",
"name": "Stroke",
"thumbnail": "thumbnail_images/1579698879.png",
"video": "videos/STROKE.m4v",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "29",
"lang_id": "2",
"medical_type_id": "27",
"name": "Dog Bite",
"thumbnail": "thumbnail_images/1579698934.png",
"video": "videos/Dogbite.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "32",
"lang_id": "2",
"medical_type_id": "7",
"name": "Allergy",
"thumbnail": "thumbnail_images/1581580973.png",
"video": "videos/Allergy.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "19",
"lang_id": "2",
"medical_type_id": "17",
"name": "Hyperthermia(Heat Exhaustion)",
"thumbnail": "thumbnail_images/1579698575.png",
"video": "videos/Hyperthermia.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "21",
"lang_id": "2",
"medical_type_id": "19",
"name": "Introduction",
"thumbnail": "thumbnail_images/1579698707.png",
"video": "videos/intro.mp4",
"video_type": "1",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
},
{
"id": "23",
"lang_id": "2",
"medical_type_id": "21",
"name": "Recovery Position",
"thumbnail": "thumbnail_images/1579698747.png",
"video": "videos/RecoveryPosition.mp4",
"video_type": "2",
"delete_status": "1",
"user_id": "ok",
"video_id": null,
"created_at": null,
"status": "0"
}
],
}
Below is my database,
enter image description here
I just want to add both the tables and it will show all the list of videos from first table but if the video is seen by the user, status will show 1 else 1.
I think you want a flag indicating if a user has seen a video. For this, I suggest EXISTS:
select v.*,
(case when exists (select 1
from video_quews vq
where v.id = vq.video_id and vq.user_id = $user_id
)
then 1 else 0
end) as has_user_flag
from videos v
I have a vega-lite chart that shows up as expected in Chrome (72.0.3626.96), but not in Firefox (70.0.1). I have checked the spec in the Vega Editor. Does anyone know why this might be?
Here are the rendered charts:
Firefox:
Chrome:
Here is the spec:
Any help you might be able to give would be much appreciated.
Apologies, but I do not know how to collapse this code.
{
"$schema": "https://vega.github.io/schema/vega-lite/v3.2.1.json",
"background": "white",
"config": {"mark": {"tooltip": null}, "view": {"height": 300, "width": 400}},
"datasets": {
"data-511198e25d4dbee99248144390684caa": [
{
"counts": 338,
"filter_method": "greater than",
"grade": "9",
"index": 3,
"perc": 0.2669826224328594,
"school_code": "Board",
"threshold": "8",
"year": 20172018,
"year_lab": "2017/18",
"year_lab_q": "2017"
},
{
"counts": 414,
"filter_method": "greater than",
"grade": "9",
"index": 4,
"perc": 0.30689399555226093,
"school_code": "Board",
"threshold": "8",
"year": 20182019,
"year_lab": "2018/19",
"year_lab_q": "2018"
}
],
"data-72a083843a98847e44077116c495e448": [
{
"counts": 49,
"filter_method": "greater than",
"grade": "9",
"index": 0,
"perc": 0.3356164383561644,
"school_code": "KING",
"threshold": "8",
"year": 20142015,
"year_lab": "2014/15",
"year_lab_q": "2014"
},
{
"counts": 62,
"filter_method": "greater than",
"grade": "9",
"index": 5,
"perc": 0.3668639053254438,
"school_code": "MLTS",
"threshold": "8",
"year": 20162017,
"year_lab": "2016/17",
"year_lab_q": "2016"
},
{
"counts": 53,
"filter_method": "greater than",
"grade": "9",
"index": 6,
"perc": 0.29608938547486036,
"school_code": "KING",
"threshold": "8",
"year": 20172018,
"year_lab": "2017/18",
"year_lab_q": "2017"
},
{
"counts": 44,
"filter_method": "greater than",
"grade": "9",
"index": 7,
"perc": 0.25882352941176473,
"school_code": "MLTS",
"threshold": "8",
"year": 20172018,
"year_lab": "2017/18",
"year_lab_q": "2017"
},
{
"counts": 53,
"filter_method": "greater than",
"grade": "9",
"index": 8,
"perc": 0.3212121212121212,
"school_code": "KING",
"threshold": "8",
"year": 20182019,
"year_lab": "2018/19",
"year_lab_q": "2018"
},
{
"counts": 61,
"filter_method": "greater than",
"grade": "9",
"index": 9,
"perc": 0.25206611570247933,
"school_code": "MLTS",
"threshold": "8",
"year": 20182019,
"year_lab": "2018/19",
"year_lab_q": "2018"
}
]
},
"height": 400,
"layer": [
{
"data": {"name": "data-72a083843a98847e44077116c495e448"},
"encoding": {
"color": {
"field": "school_code",
"legend": {"labelFontSize": 15, "titleFontSize": 20},
"title": null,
"type": "nominal"
},
"tooltip": [
{
"field": "perc",
"format": ".2%",
"title": "percentage",
"type": "quantitative"
},
{
"field": "counts",
"title": "number",
"type": "quantitative"
},
{"field": "year_lab", "title": "school year", "type": "nominal"},
{"field": "school_code", "title": "level", "type": "nominal"},
{"field": "grade", "type": "nominal"},
{"field": "filter_method", "type": "nominal"},
{"field": "threshold", "type": "nominal"}
],
"x": {
"axis": {"format": "%Y", "tickCount": 5},
"field": "year_lab_q",
"scale": {"domain": ["2013.9", "2018.5"]},
"title": "School Year (beginning)",
"type": "temporal"
},
"y": {
"axis": {"format": ".0%"},
"field": "perc",
"title": "Percentage",
"type": "quantitative"
}
},
"mark": {"point": true, "type": "line"},
"selection": {
"selector001": {
"bind": "scales",
"encodings": ["x", "y"],
"type": "interval"
}
}
},
{
"data": {"name": "data-511198e25d4dbee99248144390684caa"},
"encoding": {
"color": {
"field": "school_code",
"legend": {"labelFontSize": 15, "titleFontSize": 20},
"scale": {"domain": ["Board"], "range": ["black"]},
"title": null,
"type": "nominal"
},
"tooltip": [
{
"field": "perc",
"format": ".2%",
"title": "percentage",
"type": "quantitative"
},
{
"field": "counts",
"title": "number",
"type": "quantitative"
},
{"field": "year_lab", "title": "school year", "type": "nominal"},
{"field": "school_code", "title": "level", "type": "nominal"},
{"field": "grade", "type": "nominal"},
{"field": "filter_method", "type": "nominal"},
{"field": "threshold", "type": "nominal"}
],
"x": {"field": "year_lab_q", "type": "temporal"},
"y": {"field": "perc", "type": "quantitative"}
},
"mark": {"point": true, "type": "line"}
}
],
"resolve": {"scale": {"color": "independent"}},
"title": "A title!",
"width": 700
}
It appears that your temporal values are not being parsed correctly in firefox (details of javascript date parsing behavior is often browser-dependent). You could try forcing the correct parsing by changing your data specification (in both places) to:
"data": {
"name": "data-72a083843a98847e44077116c495e448",
"format": {"parse": {"year_lab_q": "date:%Y"}}
}
This should ensure that the year string is parsed as a year, rather than e.g. a unix timestamp.
The other place date parsing is happening is in your domain specification. You might try changing those to a more standard time format, e.g.
"domain": ["2013-11-01", "2018-06-01"]
Object {
"0": 200,
"result": Array [
Object {
"created_at": "1572602716",
"description": "i am description ",
"id": "1",
"title": "gulsan",
"updated_at": "1572602716",
"user_id": "27",
},
Object {
"created_at": "1572603684",
"description": "i am description ",
"id": "2",
"title": "kunal",
"updated_at": "1572603684",
"user_id": "27",
},
Object {
"created_at": "1572603975",
"description": "i am description ",
"id": "3",
"title": "nil",
"updated_at": "1572603975",
"user_id": "27",
},
Object {
"created_at": "1572854783",
"description": "i am description ",
"id": "7",
"title": "nilakash",
"updated_at": "1572854783",
"user_id": "27",
},
Object {
"created_at": "1573114400",
"description": "123",
"id": "8",
"title": "Tapan#gmail.com",
"updated_at": "1573114400",
"user_id": "27",
},
Object {
"created_at": "1573114522",
"description": "Test",
"id": "9",
"title": "Test",
"updated_at": "1573114522",
"user_id": "27",
},
Object {
"created_at": "1573114525",
"description": "Test",
"id": "10",
"title": "Test",
"updated_at": "1573114525",
"user_id": "27",
},
],
}
how to view it component
const obj = state.find((p) => p.title === "nil");
console.log(obj)
output
Object {
"created_at": "1572603975",
"description": "i am description ",
"id": "3",
"title": "nil",
"updated_at": "1572603975",
"user_id": "27",
}
i want show it component
Try the below snippet, you can view the object using this way.
var obj = "{\"0\": 200,\"result\": [{\"created_at\": \"1572602716\",\"description\": \"i am description \",\"id\": \"1\",\"title\": \"gulsan\",\"updated_at\": \"1572602716\",\"user_id\": \"27\"}, {\"created_at\": \"1572603684\",\"description\": \"i am description \",\"id\": \"2\",\"title\": \"kunal\",\"updated_at\": \"1572603684\",\"user_id\": \"27\"}, {\"created_at\": \"1572603975\",\"description\": \"i am description \",\"id\": \"3\",\"title\": \"nil\",\"updated_at\": \"1572603975\",\"user_id\": \"27\"}, {\"created_at\": \"1572854783\",\"description\": \"i am description \",\"id\": \"7\",\"title\": \"nilakash\",\"updated_at\": \"1572854783\",\"user_id\": \"27\"}, {\"created_at\": \"1573114400\",\"description\": \"123\",\"id\": \"8\",\"title\": \"Tapan#gmail.com\",\"updated_at\": \"1573114400\",\"user_id\": \"27\"}, {\"created_at\": \"1573114522\",\"description\": \"Test\",\"id\": \"9\",\"title\": \"Test\",\"updated_at\": \"1573114522\",\"user_id\": \"27\"}, {\"created_at\": \"1573114525\",\"description\": \"Test\",\"id\": \"10\",\"title\": \"Test\",\"updated_at\": \"1573114525\",\"user_id\": \"27\"}]}";
var jsonObj = JSON.parse(obj);
console.log(jsonObj.result[0]);