BBAzn
BBAzn•11mo ago

so i have the results come back in a

so i have the results come back in a json text but i wanna edit the string, replace certain characters etc
18 Replies
Gaurav Chadha
Gaurav Chadha•11mo ago
You can change the response type from node editor or from the code editor manually, to replace certain characters or perform any operations on the string, you can use Regex.
BBAzn
BBAznOP•11mo ago
this isnt the right syntax do you know how i can wrap it so i can return the modified string?
No description
BBAzn
BBAznOP•11mo ago
the (x)text variable is the result of an API call i wanna modify it tho, i need to clean up the string seems like the node editor just sends back the whole string instead of doing the code and then sending it back?
Gaurav Chadha
Gaurav Chadha•11mo ago
To remove the string you can use Slice method. You'll have to check if the regex is correct. You can fiind all the methods here - https://www.geeksforgeeks.org/delete-first-character-of-a-string-in-javascript/. Then include regex in it if required.
No description
BBAzn
BBAznOP•11mo ago
No description
No description
BBAzn
BBAznOP•11mo ago
i know there are alot of ways to do it but it seems like the editor isnt processing the code? or something is missing
BBAzn
BBAznOP•11mo ago
No description
BBAzn
BBAznOP•11mo ago
seems like the only thing that works in the node editor is just having the (x)text variable
Gaurav Chadha
Gaurav Chadha•11mo ago
You can confirm it by checking the value of the string (text).
BBAzn
BBAznOP•11mo ago
No description
BBAzn
BBAznOP•11mo ago
that is with just this
No description
BBAzn
BBAznOP•11mo ago
it returns a json, the (x)text is a json body result
Gaurav Chadha
Gaurav Chadha•11mo ago
Okay, the issue here is - The response is of type array, you are adding operation/method of string, you'll require to convert it to string or extract from the array index.
BBAzn
BBAznOP•11mo ago
ooo
BBAzn
BBAznOP•11mo ago
thing is the type just by itself is a string
No description
BBAzn
BBAznOP•11mo ago
the json body format is results --> text and its always a string ok so yeah it is an array i see it in the api
BBAzn
BBAznOP•11mo ago
No description
No description
BBAzn
BBAznOP•11mo ago
lol feel like this is being overly complicated the string comes back fine, i just need to trim it in buildship before it sends it to the front end actually i figured it out i found some nodes lol, the convert to string node works and then the replace string node ;D thx for the tips 😉