hello everyone. my name is jay. i've gotten to the lambda section of the challenge and encountered a minor but annoying bug:
when i load lambda URL, instead of increasing the view by 1, it's increasing it by 2. i've tried leaving it as just views = views but that just keeps the current number. the views are being counted in the dynamodb table as well. what am i missing? i've rewritten the code line by line and i still can't wrap my head around it. here's my code. i'm sorry if i spoil it for anyone:
import json
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('cloudresume')
def lambda_handler(event, context):
response = table.get_item(Key={
'id':'0'
})
views = response['Item']['views']
views = views +1
print(views)
response = table.put_item(Item={
'id' : '0',
'views' : views
})
return views