some-like-it-hot-delivery's People
some-like-it-hot-delivery's Issues
It's not an issue, It's only a question.
Can I create a file called util.js and put on the function formatReply in it?
order status doesn't change
Hi. I've wrote all the code from your book from chapter 4 and everything works well except changing order status by your api.
That's a code of the create-order handler:
`
create: req => {
if (!req.body || !req.body.pizzaId || !req.body.address) {
throw new Error("To order pizza please provide pizza type " +
"and address where pizza should be delivered");
} else {
let deliveryUrl = "https://some-like-it-hot.effortless-serverless.com/delivery";
let webhookUrl = "https://9z0y8x3sfj.execute-api.eu-central-1.amazonaws.com/latest/orders/updateStatus";
let delivery = {
pickupTime: "15.34pm",
pickupAddress: "Pizzaeria Address",
deliveryAddress: req.body.address,
webhookUrl
};
return fetch(deliveryUrl, {
method: "POST",
body: JSON.stringify(delivery),
headers: {
"Authorization": "aunt-marias-pizzeria-1234567890",
"Content-Type": "application/json"
}
})
.then(res => res.json())
.then(res => {
return docClient.put({
TableName: "orders",
Item: {
id: res.deliveryId,
pizzaId: req.body.pizzaId,
address: req.body.address,
status: "pending"
}
})
.promise()
})
.catch(error => {
throw error;
})
}
}`
That's a code of update-deliver-status:
` updateStatus: req => {
if (!req.body || !req.body.deliveryId || !req.body.status) {
throw new Error("Status and delivery ID are required");
} else {
return docClient.update({
TableName: "orders",
Key: { id: req.body.deliveryId },
UpdateExpression: "set #status = :s",
ExpressionAttributeValues: {
":s": req.body.status
},
ExpressionAttributeNames: {
"#status": "status"
}
})
.promise()
.then(() => {})
.catch(error => {
throw error;
})
}
}`
What really strange is that create-handler works okay, and you can even change status manually:
curl -i -H "Content-Type: application/json" -X POST -d '{"deliveryId": "b2902e2f-1d53-4dae-a497-b6f78b299209", "status": "delivered"}' https://9z0y8x3sfj.execute-api.eu-central-1.amazonaws.com/latest/orders/updateStatus
So i guess something wrong with timing on the side of the api, you can check the result of the top curl on that path: https://9z0y8x3sfj.execute-api.eu-central-1.amazonaws.com/latest/orders
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.