Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
¿Por qué el contador de vistas se muestra indefinido?

Estoy completamente perdido, he estado tratando de resolver esto durante casi 2 días. Aquí está mi código, si necesita más información, hágamelo saber. Necesito un descanso, así que no estoy en mi mejor momento. Creé una cuenta para esto, así que no tengo suficiente estado para publicar imágenes incrustadas.

Código JS como texto

 const countUrl = 'https://igf5ctozsa.execute-api.us-east-1.amazonaws.com/default/updateViews' const countElement = document.getElementById('count'); updateViewCount(); function updateViewCount() { fetch(countUrl) .then(res => res.json()) .then(res => { countElement.innerText = res.val; }); }

API de Python como texto

 import json, boto3 client = boto3.client('dynamodb') TableName = 'cloud-resume-stats' def lambda_handler(event, context): response = client.update_item( TableName='cloud-resume-stats', Key = { 'stats': {'S': 'viewcount'} }, UpdateExpression = 'ADD Quantity :inc', ExpressionAttributeValues = {":inc" : {"N": "1"}}, ReturnValues = 'UPDATED_NEW' ) val = int(response['Attributes']['Quantity']['N']) return { 'statusCode': 200, 'headers': { 'Access-Control-Allow-Headers': '*', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': '*' }, 'body': val }

Respuesta API como texto

 Test Event Name TestEvent Response { "statusCode": 200, "headers": { "Access-Control-Allow-Headers": "*", "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "*" }, "body": 147 } Function Logs START RequestId: 25413898-aca7-45e7-869e-41dd94879af4 Version: $LATEST END RequestId: 25413898-aca7-45e7-869e-41dd94879af4 REPORT RequestId: 25413898-aca7-45e7-869e-41dd94879af4 Duration: 75.93 ms Billed Duration: 76 ms Memory Size: 512 MB Max Memory Used: 63 MB Init Duration: 339.61 ms Request ID 25413898-aca7-45e7-869e-41dd94879af4
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Según el valor de la parte del cuerpo de la respuesta de la API de Python, creo que res es solo 147 , no res.val .

 fetch(countUrl) .then(res => res.json()) .then(res => { //countElement.innerText = res.val; // res is 147 countElement.innerText = res; });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!