I have a Typescript interface that I need to convert to a string to send to an API endpoint.
This is the object (as printed from the console using console.log()
{name: "John", avatarId: 1, forwardRelationship: "WIFE", reverseRelationship: "HUSBAND"}
I initially tried JSON.stringify() to turn it into a string that the API would be happy with which outputs the following:
{"name":"John","avatarId":1,"forwardRelationship":"WIFE","reverseRelationship":"HUSBAND"}
The API needs just the one string though so:
"{name:John,avatarId:1,forwardRelationship:WIFE,reverseRelationship:HUSBAND}"
Is there a function I do this with shorthand? Or do Need to build the string up manually using each property?