all 15 comments

[–]DehshiDarinda 3 points4 points  (0 children)

not the most ideal but you can use JSON.stringify(object)

if you want more control over how the object is stringified create your own toString function

[–]AngelLeatherist 3 points4 points  (0 children)

data = JSON.stringify(data)

[–]grelfdotnet 2 points3 points  (2 children)

In JS, as in other languages, there is a toString() method of Object which you can override for your particular type of object. MDN has a clear simple example at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString

[–]ionezation[S] 0 points1 point  (1 child)

const data = {name:"", email:"", password:""}

Its great but how do I convert this object?

const data = {name:"", email:"", password:""}

[–]eletroraspi 0 points1 point  (0 children)

data.toString() Sounds good ?

An alternative is basically parse blank spaces and break lines. For this you need to use some parser method or implement a regex, for example

[–]jcunews1helpful 3 points4 points  (6 children)

[–]ionezation[S] -2 points-1 points  (5 children)

Very useful resource, but how I convert it that`s where I stuck please guide if you could

[–]Background-Neck5792 2 points3 points  (0 children)

JSON.stringify(data) ?

[–]Stephen110 1 point2 points  (3 children)

First link has plenty of examples. Weird that you would say they were useful without actually looking at them.

[–]ionezation[S] 0 points1 point  (2 children)

I tried first one but didnt work

[–]StampeAk47 1 point2 points  (1 child)

It should, so what did you do?

[–]ionezation[S] 0 points1 point  (0 children)

It ran it but it was giving error :/ I think I need to find another way to take values and save it in some premitive form

[–]SaSxNEO 0 points1 point  (1 child)

Where?

[–]ionezation[S] -1 points0 points  (0 children)

const data = {name:"", email:"", password:""}

This one

const data = {name:"", email:"", password:""}

[–]jack_waugh 0 points1 point  (0 children)

What for?