Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
How to enter multi-line strings in REST Client for VS Code?

EDIT There's some confusion about what I am storing. I am making a code snippet web app in Express.js and Mongodb. I am not storing code to execute it later, I am storing it, and then displaying it in plain-text on the web app, and will allow the user to copy the code to use themselves. I have a syntax highlighter module installed to make it look good, but the code itself is not executed.

It is similar to GitHub Gists.

Another Edit How can I store multi-line text in Mongodb, then when fetched from server, convert it automatically to use \n for line breaks, and \t for tabs?

I am making a REST API in Express.js. I am using Rest Client extension in VS Code to test out the API.

I am making a post request to the server to create a code snippet. The fields for the snippet model are all strings, but I need one field to hold actual code inside it. I tried using backticks and a few other things, but cannot seem to figure it out.

Here's my file "api.rest"

@hostname = localhost
@port = 5000
@host = {{hostname}}:{{port}}
@contentType = application/json

# POST /users
POST http://{{host}}/snippets HTTP/1.1
Content-Type: {{contentType}}

{
    "title": "React Component",
    "code": "CHANGE THIS TO A MULTI-LINE JAVASCRIPT CODE SNIPPET",
    "creator": "nero1333"
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your use case is very simple. You just want to save text input in the database and fetch it later to display on the client-side.

You just have to send the code in string form containing \n for a new line, \t for tabs, and \" to escape the double quotes used in the code.

If you are taking input from a text editor using a webpage, that editor will escape these values for you and you will send it to the server to store.

For example:

You want to save this code as you mentioned in the comment:

import React from 'react'
class className extends React.Component
    render() {
        <div></div>
    }

Send it like:

{
    "code": "import React from 'react'\nclass className extends React.Component\n\trender() {\n\t\t<div></div>\n\t}"
}

Same way you will enter it in the REST client to test the API.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda