i created a simple lambda function like calling api url and i have import requests library in my lambda function and i downloaded requests library in my local machine with command (pip3 install requests -t ) and zipped the folder and added as a layer in my lambda function but am getting below error.
Here my lambda function:
import json
from config import base_url
import requests
def lambda_handler(event, context):
res = requests.get(url=base_url+'todos/1')
return {
'statusCode': res.statusCode,
'body': res.json()
}
config.py file:
base_url="https://jsonplaceholder.typicode.com/"
Response:
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'requests'",
"errorType": "Runtime.ImportModuleError",
"requestId": "486a7cda-4162-4809-bcb8-cb12bf640e60",
"stackTrace": []
}