javascript – Método Put retorna Bad Request no Front-end com React

Eu fiz uma aplicação com React que faz um CRUD. Todos os métodos estão funcionando perfeitamente, com exceção do PUT. Eu quero atualizar um registro que está em JSON mas, pelo React eu não consigo. Retorna 400 – Bad Request. Se eu testar o mesmo endpoint com o Postman, funciona perfeitamente. Já conferi o código no front-end, verifiquei tutoriais mas não encontro a resposta. Obrigado!

Log do erro

/* API ADDRESS */
const API_URL = 'http://localhost:3005/';
    
async function updateBook(values){
  console.log(values); 
  const res = await axios.put(`${API_URL}update`, values);    
  return res.data.books;  
}

Is it a bad idea to have a single event bus service for the whole organization?

Assumed that the whole organization is doing the related product,

Is it a bad idea to have a single event bus service for the whole organization?

Are we going to have any scaling issues for that?

dungeon world – So what do I do when a player gets bad luck at the start of the session?

To answer ‘what should I do?’, the answer is probably:

Ask the player if they had a good time. Ask them if they enjoyed the story. If the answer is “yes”, then you did everything right.

To answer ‘how to make the encounter easy’, the Dungeon World answer is: you don’t.

It’s not your job to make encounters easy or hard. It’s your job to be a fan of the characters, and it’s your job to fill their lives with adventure. These are your agendas, and it sounds like you followed them perfectly well.

If players have bad luck, that just means you’ll be in the “The hero is being challenged and is failing” part of the story, and it means they’ll earn XP and grow and come back stronger in the end. It’s not a problem at all (assuming the player is having fun)

Remember that Lord of the Rings features the early part where Frodo gets stabbed by a Ring Wraith and then needs to be saved by Aragorn, and then almost dies, and then needs to be saved again when traveling to the safety of Rivendell and then again by Elrond’s healing. I don’t think anybody considers it a bad story because the first encounter wasn’t easy.

web development – Should server return error page or render form again on 400 Bad Request

I have a basic web app (not api) with pages and forms. If a user sends a for e.g. register form with values that cannot be validated, I render the form page again with status 422 indicating where faulty inputs were made.

When the syntax however is wrongly formed, should an error page be displayed to the user with the code 400 Bad request, or should it render the register form page again with a message saying that the request body was malformed (response still 400)?

My thoughts:
Arguments for error page: It seems that there is something wrong with the frontend (client) if it sends POST requests without or with a wrong body. Either the frontend has to be fixed, or the request body was manipulated. This should never happen* if the user sent the form normally and the frontend is not faulty.

*Why I doubt: I’m not 100% sure that it’s impossible that it could be a temporary error of the client or maybe a network issue or something else. If this is plausible, then the user has to be redirected to the form again with the info that the request body was wrong. He should be able to try again.
My related question basically is this: is it possible that in the normal flow of actions the server receives a request with a faulty body?

seo – Acquired domain name linked to bad reputation on search engines due to previous owner

If a example.com is purchased, but has a history of fraud or some other heinous crime by its previous owners, such that search engine results show 10 pages and more of complaints from defrauded investors or victims on various web forums, what can they new owner and webmaster of the domain do to clean up those search results, or be able to separate itself from its checkered history which has no connection whatsoever to the new owner?

Is negative SEO the only thing that can be done? what else? especially to prevent those victims from claiming that their abuser is back online?

Why is crossing paths bad in Traveling Salesman?

I’m learning about Traveling Salesman in an online course (sorry I can’t share the link it’s paid only) and the first step to solving it then just state "as a heuristic we avoid crossed paths" and never really explained why. Why are crossed paths bad in traveling salesman?

c# – Is it bad practice to do additional work in IAsyncEnumerable generator method?

Imagine you have to process each row in large table.
For every single row you have to download some data from a web service and store it in a different database.

InfrastructeOverview

Loading all rows at once into the ConsoleApp’s memory consumes too much resources and takes too long.

It’s important to mention that the table will no longer modified, only Select statements are possible and the data can be queried ordered by the primary key which is an integer value.

A possible solution is to load one row after another.
For doing so you need two things.
Firstly, the table must be queryable in an ordered manner (unique index).
Secondly, you need to know the last loaded row to get the next one.

A simple example using IAsyncEnumerable could look like the following.

  async IAsyncEnumerable<Data> GetRowsAsync()
  {
    // primary key starts at 1
    var lastId = 0;
    while(true)
    {
      Data next = await LoadNextRowAsync(lastId); // where id is greater than lastId

      if(next is null)
      {
        break;
      }

      yield return next;

      lastId = next.Id
    }
  }

But making a network call for each row creates an overhead that makes the app feel like it never ends.

The first way that comes in mind to avoid that overhead is to load n rows rather than 1 row.

  async IAsyncEnumerable<Data> GetRowsAsync()
  {
    var lastId = 0;
    while(true)
    {
      List<Data> nextRows = await LoadNextRowsAsync(lastId: lastId, nElements: 500);

      if(!nextRows.Any())
      {
        break;
      }

      yield return nextRows;

      lastId = nextRows.Last().Id
    }
  }

Great, this makes the app much faster.
But it still takes a while till all rows have been processed.

After some time the app crashed due to a bug and the last id got lost.
So I have to start from scratch again after fixing the bug and I can’t garantuee that there are no more bugs.
This leads to a new requirement.

I want to be able to stop processing rows and continue later without starting from the beginning.

The easiest way to achieve this is by persisting the lastId, e.g. in a file located in the output directory of the app.

  async IAsyncEnumerable<Data> GetRowsAsync()
  {
    while(true)
    {
      // load last id from file in out directory
      var lastId = await GetLastIdOrDefaultAsync();

      List<Data> nextRows = await LoadNextRowsAsync(lastId: lastId, nElements: 500);

      if(!nextRows.Any())
      {
        break;
      }

      yield return nextRows;

      // save last id in file
      await UpdateLastIdAsync(nextRows.Last().Id);
    }
  }

This works fine and fulfils all requirements.
Now to my actual question.

Do I abuse IAsyncEnumerable in my final solution?

In almost all examples I’ve seen IAsyncEnumerable is used in much simpler ways and I wonder if it is bad practice to do that additional IO for storing ids inside the generator method.

data leakage – Exposing employee numbers, how bad is it?

I’ve realised that there is an easy way for someone who is external to figure out valid employee numbers at my company.

And I’m fairly sure they could then be linked to a full name easily too.

I’ve raised this as a concern with our security team as I don’t particularly like the idea but it’s been brushed off as a fairly harmless thing to know valid employee numbers. I feel my concern over linking it to names as well missed or skipped over.

Am I right to be concerned or am I overthinking it? I don’t really want to push back or do further testing if I’m being irrational.

encryption – Hill Cipher: Determining the number of bad keys

Find the number of matrices whose determinant is a multiple of 13 where the first column is not a multiple of 13 but the second column is a multiple of the first modulo 13

But here’s what I did:
The number of combinations when the first column is not multiple of 13 is (26^2-2^2) = 2^2×(13^2-1)
The number of combinations when the second column is multiple of 13 is 2^2
Thus, the total combinations: 2^4 × (13^2 – 1)

The solution given is: 2^4 × (13^2 – 1) x 13

Please advise!

Is using DeepL translation good or bad for SEO?

I saw using Google translation is clearly bad because you’re doing automatic translation without decent human revision also Google can confirm that you are using Google translation. But how about DeepL translation, that enables you high quality translation for some languages, different from Google translation or Bing translation? Can Google robot recognize content that created from DeepL, or very high quality machine translation?