• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

200
Vistas
For search using API I am sending the input to the backend using string interpolation in react

I am sending like "oemName": %${''}% which works fine but without % it doesnt work which is making me wonder why its happening.

const getEquipmentNameSearch = async (SearchText?: any) => {
    console.log("Args", SearchText)

    try {
        const responseData: any = await client.query({
            query: SEARCH_EQUIPMENTS_BY_NAME,
            variables: {
                "oemName": SearchText === undefined ? `%${''}%` : `%${SearchText}%`,
                // "oemName": `${''}`
            },
            fetchPolicy: 'network-only',
            context: { role: MasterMaterialRoles.read },
        });
        const filteredResult = responseData.data.equipmentMaster?.filter((item: any) => item.oemName.toLowerCase().includes(SearchText?.toLowerCase()))
        const responseDataList = SearchText ? filteredResult : responseData.data.equipmentMaster
        dispatch({
            type: GET_EQUIPMENT_MASTER,
            payload: responseDataList,
        });

    } catch (error: any) {
        console.log('err:', error)

    }
}

On directly using ${''} I am getting '' in payload but nothing is getting rendered on the page.

Payload

about 3 years ago · Juan Pablo Isaza
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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda