Delay an angular.js $http service

前端 未结 8 1268
感动是毒
感动是毒 2021-01-31 16:32

I have some angular factories for making ajax calls towards legacy ASP.NET .asmx web services like so:

module.factory(\'productService\', [\"$http\",
function ($         


        
8条回答
  •  忘掉有多难
    2021-01-31 16:46

    In response to the testing aspect of your question, Fiddler has a really useful function that helps when you need to simulate delays:

    1. Click on the AutoResponders tab in Fiddler.
    2. Add a rule with a regex that matches the URL of the request you want to delay.
    3. Set the "respond with" to "*delay:1000" where the number is the delay in milliseconds.

    The AutoResponder functionality in Fiddler is extremely useful for testing JS that involves a lot of http requests. You can set it to respond with particular http error codes, block responses, etc.

提交回复
热议问题