DEV Community

Discussion on: Build a RESTful API with the Serverless Framework

Collapse
 
mshaikhcci profile image
Mubina Shaikh

Hi Sagar,

Thank you for sharing, upon changing serverless.yml runtime to nodejs12.x, i am not getting the error i mentioned in previous comment.

I am attaching screenshots of calling API in postman i dont get response as shown in your article, and get pokemon by id API doesnt work at all.

Please let me knoew how to get data of API correctly.

Thread Thread
 
mshaikhcci profile image
Thread Thread
 
mshaikhcci profile image
Mubina Shaikh
Thread Thread
 
mshaikhcci profile image
Mubina Shaikh

Also, I tried to debug by putting console statements in index.js file API's but console statements are not printed in BE.

app.get('/pokemon/', (req, res) => {
const query = 'SELECT * FROM pokemon_tb'
pool.query(query, (err, results, fields) => {
if (err) {
const response = { data: null, message: err.message, }
console.log('***********', response);
res.send(response)
}

    const pokemons = [...results]
    const response = {
        data: pokemons,
        message: 'All pokemons successfully retrieved.',
    }
    res.send(response)
})

})

please tell me why ?

Thread Thread
 
sagar profile image
Sagar

IDK exact reason behind this. you need crosscheck function with the article mention code blocks and also you've to debug the root cause of this.

Thread Thread
 
mshaikhcci profile image
Mubina Shaikh

Hi, i had crossed checked function code blocks with article code blocks, its the same.
Can please tell me why console statements arent printing, it should print right ?