0

I've created a REST export view to get a paragraph field in a JSON format but I cannot get the result properly, so I used Rest Views module but I got the results including something like these characters \u003Ca href=\u0022\/colors\/gray-metallic\u0022 hreflang=\u0022en\u0022\u003EGray Metallic\u003C\/a\u003E

Also, this paragraph field includes a term reference field.

So I want to render the data properly without these characters and as a plain text

1 Answer 1

0

I have solved by using jQuery.parseHTML() or you can use Javascript DOMParser

Something like this

$.ajax({ type: 'GET', url: drupalSettings.path.baseUrl + 'REST_VIEW_PATH/' + nid, success: function (data) { { var paragraphField = data[0]['FIELD_NAME']; $.each(paragraphField, function (index, item) { var fieldItem = $.parseHTML(item.FIELD_ID_IN_PARAGRAPH); console.log(fieldItem[0]['innerText']); }); } } }); 
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.