Skip to content

Commit

Permalink
fix: update via event id
Browse files Browse the repository at this point in the history
  • Loading branch information
mati007thm committed Jan 19, 2024
1 parent 4074ee2 commit 37c101a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 2 additions & 3 deletions dapr-distributed-calendar/locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ def event_lifecycle(self):
updated_data = {
"data": {
"name": f"Updated Event {event_id}",
"date": "2020-10-10",
"id": str(event_id)
"date": "2020-10-10"
}
}
response = self.client.put(f'/updateevent', json=updated_data, headers=headers)
response = self.client.put(f'/updateevent/{event_id}', json=updated_data, headers=headers)

# Check if the update was successful
if response.status_code == 200:
Expand Down
16 changes: 11 additions & 5 deletions dapr-distributed-calendar/node/node_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,25 @@ app.get('/event/:id', (req, res) =>{
});
})

app.put('/updateevent', (req, res) => {
app.put('/updateevent/:id', (req, res) => {
updateEventCounter.add(1);

const data = req.body.data;
const eventId = data.id;
console.log("Updating event! Event ID: " + eventId);
const key = req.params.id;
const body = {
"name": data.name,
"date": data.date,
"id": key
}

console.log("Updating event! Event ID: " + key);

console.log("Data passed as body to Go", JSON.stringify(data))
console.log("Data passed as body to Go", JSON.stringify(body))

// Assuming your Go service has an endpoint like '/updateEvent'
fetch(invokeUrl + `/updateEvent`, {
method: "PUT", // Use PUT method for updating
body: JSON.stringify(data),
body: JSON.stringify(body),
headers: {
"Content-Type": "application/json"
}
Expand Down

0 comments on commit 37c101a

Please sign in to comment.